I'm trying to make a Life Support Control chip for my Gas Systems 3 components.
When I first spawn my ship, obviously everything is 0 so I want to turn on the collectors to start collecting Tritium, Methane, and Deuterium.
Once these have maxed out, I would like my Inverters to turn on so that I will start generating Oxygen, Water, and Nitrogen.
When my Tritium level gets to 10%, I would like the Tritium Inverter to turn off until Tritium is at 100% again (same for other 2 gas types)
So I should see my Tritium level increase until it gets to 100%, then go down to 10%, then back up to 100%, then down to 10% until Oxygen is at 100%
However, with the code below, it goes from 0% to 100%, then down to 10%, and hovers around 10%. The inverters switch on and off every second or so.
The Tritium Collector should stay on until Oxygen = 100% and Tritium = 100%
I'm sure I may just be tired, but maybe someone will solve this by tomorrow night
This is just a piece of the code. LastTritium is the Tritium value of the previous clock cycle. PctTritium is the current Tritium value divided by the max.
(LastTritium >= GS3StorageCache["Tritium",number]) should in essence be saying
if Tritium is discharging
But I think that line is most likely where I am screwing up.
Trit_Inverter_On = 0
Meth_Inverter_On = 0
Deut_Inverter_On = 0
if ((PctOxygen < 1) & (LastTritium >= GS3StorageCache["Tritium",number]) & (PctTritium > 0.1) ) {
Trit_Inverter_On = 1
}
if ((PctWater < 1) & (LastMethane >= GS3StorageCache["Methane",number]) & (PctMethane > 0.1) ) {
Meth_Inverter_On = 1
}
if ((PctNitrogen < 1) & (LastDeuterium >= GS3StorageCache["Deuterium",number]) & (PctDeuterium > 0.1) ) {
Deut_Inverter_On = 1
}
Trit_Collector_On = (PctOxygen < 1) | (PctTritium < 1)
Meth_Collector_On = (PctWater < 1) | (PctMethane < 1)
Deut_Collector_On = (PctNitrogen < 1) | (PctDeuterium < 1)
Thanks in advance,
Kevin