Jump to content

How to consume fuel like an engine?


Recommended Posts

Hi,

I made a fuel dump plugin today because I always destroy my engines and I then want to get rid of the extra weight of the unused fuel, it works but is primitive because I just check all parts of the current craft and decrease their amount of fuel when they are liquid fuel tanks.

I whould like to make it consume fuel in the way the liquid engine does, but I have no idea how to do this.


{
if(UnityEngine.Input.GetKey(UnityEngine.KeyCode.O) || DumpStarted)
{
if (DumpCantStop)
DumpStarted = true;
foreach (Part p in vessel.parts)
{
if (p is FuelTank && (p.State == PartStates.ACTIVE || p.State == PartStates.IDLE))
{
FuelTank f = (FuelTank)p;
f.fuel-=DumpAmount*UnityEngine.Time.deltaTime;
}
}
}
}
  protected override void onPartUpdate()

Link to comment
Share on other sites

I think there\'s a Part.RequestFuel() method, or something along those lines. That should consume fuel in the same way that engines do, so if your fuel-dump part is above some tanks, it probably won\'t pull fuel from them. (You might be able to call RequestFuel() on another part, though.)

Link to comment
Share on other sites

OK I\'ll try around a bit...

Edit: Only works below the tanks, not above. Next I\'ll try out radial placement and fuel crossfeed, and maybe getting a part below the tanks under the dump thingy and using it as consumer.

Edit2: Works with fuel crossfeed between engine and tank, also with a fuel line connecting a tank directly to the dump thingy. I did\'nt get the standard RCS tank variation I used for testing to be placed radially, but it should work too (maybe I\'ll try this later). The only missing thin is some particles, then it should be finished :D

Link to comment
Share on other sites

Well I got it working in this simple way:

if (RequestFuel(this, DumpAmount * UnityEngine.Time.deltaTime, getFuelReqId()))

(If is there because i want to emit particles when dumping)

I bet your code whould go around the placement limitations, right?

Edit: Urgh. No idea how to spawn particles at the origin of my part. Rest is fine (altrough my test part is underpowered, but that is .cfg editing).

Link to comment
Share on other sites

That didn\'t help. I also had a look at Cepheis decompiled code (when I found out that his IonEngine was decompiled, not because it was decompiled and I wanted to steal from the devs) but I didn\'t get the particle system. The only thing I know is that there is a class called FXGroup for particles and it looks very simple, so I\'ll try that out.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...