Jump to content

part.RequestResource: draining a resource


Recommended Posts

I've just noticed that part.RequestResource doesn't seem to drain a resource down to 0? I've worked around it for my own resources, but when it comes to electric charge, trying to set the amount to 0 doesn't seem to work (probably because electric charge is a property of the vessel?).

So, how can I set the amount of electric charge to 0, or, preferably, have the function drain whatever resource I request to 0?

Link to comment
Share on other sites

You can use Part.GetConnectedResources (I believe that's the name) to get a list (it's an awkward pass-by-ref syntax) of objects which represent a resource capacity and current amount for each connected part. This takes fuel routing into account, but for ElectricCharge the routing rules allow you to get access to any part so you can just call this on the vessel root. Then you can set the current amount on each of those to zero.

If I may suggest: you could use this to build an improved RequestResource, which many of us would love to see!

Link to comment
Share on other sites

i have also seen some poor behaviour from this function. might i suggest that it has bugs and it would be nice if they were fixed? other than the fuel feeds and connectivity issues there isn't anything fantastically difficult about implementing this that i can see (looking naively from the outside)...

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...