Jump to content

How to refuel a vessel


kulesz

Recommended Posts

Hi,

I\'m writing a plugin and I need to refuel a vessel. How can I do it?

I know I can get the \'fuel\' property from FuelTank and add some value, but it allow me to overflow its original capacity.

Is there a method to add reasonable amount of fuel to all tank, not exceeding their capacity?

Link to comment
Share on other sites

Here\'s the solution that first comes to mind:

1) Right when you load the craft in, traverse the part hierarchy, and get some sort of unique ID for each part (a hash or something, not sure exactly how that would be implemented)

2) For each part, find out its current fuel, and save that to a list somewhere, mapped to that unique ID

3) When you want to refuel the craft, lookup each part in the hierarchy, and use your map to determine its original max fuel.

There are some edge cases, but maybe this general idea would work?

Link to comment
Share on other sites

Yep, I thought about such solution and it seems quite good for me - although it may be a little bit complicated. I just wanted to check if there\'s some simpler, 'generic' way to do so (just like FuelTank.RequestFuel(), but in other direction :-))

Link to comment
Share on other sites

  • 1 month later...
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...