# kRPC Question

## Recommended Posts

Hi everybody!

I've been playing with kRPC, and loving the fun of learning how to Python (which is how I justify playing more Kerbal) and have a question that's stumped me the last few days.

I have a craft with a central LFO engine, surrounded by decoupler attached LFO booster stacks.  I'm looking for a way to determine when the fuel tanks that are radially attached are empty.

Currently, I can call resources in a specific stage, which includes the main engine, and I can call object instances of all engines.  Neither of those, however, help me, because the total resource level will never equal zero before I need to jettison tanks, and I cannot seem to pinpoint a singular engine instance to test for whether the engine has_fuel.  I can test if all the engines have fuel, returning true if any single one still does, which also doesn't get me a usable result.

Finally, I've tried to mathematically calculate the usage of propellant based on the stats of the engines, but the central and radial engines are different rates, and I also have vernor engines that differ in consumption, so my attempt to compute a hard time limit on the burn without, of course, first just running the rocket on the stand (which kinda defeats the purpose I'm looking for) failed.

Any help is appreciated!  Thanks all for any insight, this has been a really good challenge, but I'm breaking down and asking for help.
Cheers!

##### Share on other sites

Firstly, you'd get a faster response just posting in the KRPC thread.  It's where those of us that fiddle with it look more often!   Secondly -  there are several ways to do it.   Perhaps the easiest is to check the decouple stage!

All parts have two stage numbers... the stage they activate in and the stage they decouple in!  If you have those radially attached tanks decoupling at some point in the tree...  you can use that to differentiate them.

Or you can iterate through the part tree.   Engines have a 'has fuel' property you can check -  so you could iterate through all engines with a given stage and test that.  https://krpc.github.io/krpc/python/api/space-center/parts.html#engine

Also there's apparently a collection of active engines that already knows if the engine has fuel?   This example shows how to grab it... so you might be able to save a copy of the list.. then compare it later with the current one to see if it's changed?   https://krpc.github.io/krpc/tutorials/parts.html#combined-specific-impulse

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account