Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

STAGE structure always returns 0 on subelements. #208

Open a1270 opened 10 years ago

a1270 commented 10 years ago

Using the Kerbal x with module attached.

PRINT STAGE:LIQUIDFUEL.
0

This is using the current master. Seems to apply to all subelements.

palaslet commented 10 years ago

Works for me. Are you sure you have any fuel on the active stage? Eg. First stage isn't activated because you're still on the launchpad?

a1270 commented 10 years ago

I am glad you're here. I didn't think being on the pad would affect that. I have been doing most of my testing on the launchpad. I have done a few launches now and it seems values only change if it's different than the max amount. You can also give stage any subelement and it will return 0.

print stage:whynamesomethingthis.
0

Probably missing a check somewhere.

a1270 commented 10 years ago
            var activeEngines = VesselUtils.GetListOfActivatedEngines(vessel);
            return Utils.ProspectForResource(resourceName, activeEngines);

That seems to be why you can't get values without firing an engine. I'll keep looking into it.

a1270 commented 10 years ago

There really isn't a good way to get information about a stage.

palaslet commented 10 years ago

Yes it is. activeEngines is a great place to start. It lists all engines that can be started on the current stage. They don't need to be throttled up to show in this list. I think the problem lies in Utils.ProspectForResource

Seems like it assumes all resources need cross feed capability. monopropellant and electricCharge does not need that while solidFuel does not support cross feed.

a1270 commented 10 years ago

Adding a check seems to be one way to fix that. But I think i'll let better minds work on this. I had a brainstorm during lunch and managed to recreate ship:resource in the most convoluted way. I'll stick to docs and simple fixes for now.

palaslet commented 10 years ago

@a1270, I've done a preliminary effort to solve this in this commit: https://github.com/palaslet/KOS/commit/e89943e76fb54cb8e2fe2f64accb9e737de9e534

Would you be so kind to take a look?

a1270 commented 10 years ago

@palaslet, nonfuelfeed resources are returning as you'd expect. It's somewhat similar to the route my attempt took but yours is much better. The one issue i have is it fails in a jarring way aka suffix 'liquidfuel' not found on object. That should fail in a way scripts can handle. Maybe zero or false.

a1270 commented 10 years ago

I will also say that your code will supersede mine so just tell me the issues we overlap and i'll close them. For now i am going to eat supper.

a1270 commented 10 years ago

Did some more testing and i can say it's even more accurate than the gui. Using the Kerbal X, the gui claims only electriccharge is in the stage during asparagus, your new code shows the LF and OX as well as electriccharge. I don't recall if that is in the old code or not.

palaslet commented 10 years ago

A note to the way I have implemented the resource prospecting: It shows what resources is available TO the current stage. Not what resources are IN the current stage. Just so we're all clear. :)

a1270 commented 10 years ago

ah, so the gui shows what's in the stage. I had always assumed it was usable to the stage.