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
@tonkepen100
Copy link

Excepcional

@tonkepen100
Copy link

Bdurrer... I have the filters, associated with refrigeration units, I see that there are two free spaces, it would be possible to tell the code that they are always on and in working mode.

The problem is that the refrigerators always go out.

Thank you.

@bdurrer
Copy link
Author

bdurrer commented Jun 24, 2019

Uh I don't get it... is this a problem you have with the code or a feature request? You want to add control for a cooling system?

@tonkepen100
Copy link

Thanks for your answer...

Yes, I would like that in your code, there was the management function of the refrigerators.

Sorry for my English, the question would be that also managed the refrigerators.

I leave a picture, to see if you understand it a little better, Ok?

Captura1

Thanks for everything.

@bdurrer
Copy link
Author

bdurrer commented Jun 25, 2019

You want to have the cooler running whenever the filter is on, right?

  1. add an alias: alias Cooler d4 at the top
  2. on line 105, before s Atmos On NewAtmosState​, add s Cooler On NewAtmosState​

if you have a second cooler, repeat it with
alias Cooler2 d5
s Cooler2 On NewAtmosState​

@tonkepen100
Copy link

----- You want to have the cooler running whenever the filter is on, right?

If I want to, but there is an associated problem. That they turn on, that is to say ON, is not a problem. The problem is that they turn ON, (Switch) and at the same time they are activated (START). Because I do not know what happens when I enter the game, they are ON, but not in START mode. I mean they go out.

On the other hand, also if you observe another problem, if we say that they only start when the filter is ON, the temperature of the tank will not be maintained, since it will be extinguished when the filter gives the order to turn off. The issue would be an order to tell them that they were always active.

Atmospherics_front

And really, I thank you very much for your interest. Thanks again.

@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