Skip to content

Instantly share code, notes, and snippets.

@bdurrer
Created February 9, 2019 22:34
Show Gist options
  • Save bdurrer/e7b569361493d131f32644dad56e7113 to your computer and use it in GitHub Desktop.
Save bdurrer/e7b569361493d131f32644dad56e7113 to your computer and use it in GitHub Desktop.
Stationeers: Filter and Storage Tank IC Controller with automatic gas type detection
alias Tank d0​
alias Atmos d1​
alias SafetyVent d2​
alias WasteTank d3​
alias TankPressure r0​
alias AtmosOn r1​
alias SafetyOn r2​
alias WastePressure r3​
alias WasteRatio r4​
alias WasteSpecPress r5​
alias WasteTriggerHi r6​
alias GasType r7​
alias temp1 r8​
alias temp2 r9​
alias TankPressHigh r10​
alias NewSafetyState r12​
alias NewAtmosState r13​
# determine target gas, only once when booting​
l TankPressure Tank Pressure​
brgtz r0 2​
hcf # exception: cannot determine gas in empty tank​
move WasteTriggerHi 2000​
move GasType 0​
l r0 Tank RatioOxygen​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% Oxygen​
move WasteTriggerHi 1000​
move GasType 1​
l r0 Tank RatioCarbonDioxide​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% CO2​
move WasteTriggerHi 500​
move GasType 2​
l r0 Tank RatioNitrogen​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% Nitro​
move GasType 3​
l r0 Tank RatioPollutant​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% X​
move GasType 4​
l r0 Tank RatioVolatiles​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% Hydrogen​
move GasType 5​
l r0 Tank RatioWater​
sgt r0 r0 0.6​
bgtz r0 loop # it's 60% Water​
loop:​
l TankPressure Tank Pressure​
l AtmosOn Atmos On​
l SafetyOn SafetyVent On​
l WastePressure WasteTank Pressure​
# if tank is critical, activate safety vent​
sgt NewSafetyState TankPressure 58000​
sgt TankPressHigh TankPressure 50000​
blez TankPressHigh regularCheck​
# high pressure: stop atmos, abort all checks​
move NewAtmosState 1​
j loopEnd​
# load the specific gas pressure​
regularCheck:​
mul temp1 GasType 2​
add temp1 temp1 2​
jr temp1​
l WasteRatio WasteTank RatioOxygen​
j check​
l WasteRatio WasteTank RatioCarbonDioxide​
j check​
l WasteRatio WasteTank RatioNitrogen​
j check​
l WasteRatio WasteTank RatioPollutant​
j check​
l WasteRatio WasteTank RatioVolatiles​
j check​
l WasteRatio WasteTank RatioWater​
check:​
mul WasteSpecPress WasteRatio WastePressure​
bgtz AtmosOn checkAtmosOn​
sgt NewAtmosState WasteSpecPress WasteTriggerHi​
jr 3​
checkAtmosOn:​
sgt NewAtmosState WasteSpecPress 100​
loopEnd: # change device states, if required​
#s db Setting NewAtmosState​
# breq NewAtmosState AtmosOn 2​
s Atmos On NewAtmosState​
# breq NewSafetyState SafetyOn 2​
s SafetyVent On NewSafetyState​
# show the state on the chip​
mul temp1 NewAtmosState 100​
mul temp2 NewSafetyState 10​
add temp1 temp1 temp2​
add temp1 temp1 GasType​
s db Setting temp1​
#s db Setting WasteSpecPress​
yield​
j loop
@bdurrer
Copy link
Author

bdurrer commented Jul 5, 2019

Ok, so the following code snippet checks that your AC is always on and is started when is not running:

l r14 Cooler On
brgtz r14 2
s Cooler On 1
l r14 Cooler Open
brgtz r14 2
s Cooler Open 1

add it at the top of the loop, e.g. line 65
You also need the alias on top of the code: alias Cooler d4

PS: ACs are very power hungry, passive radiators and wall coolers are much more effective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment