RedditPP Mascot

RedditPP

r/Stationeers • … • u/EvilFroeschken

IC10 - control centrifuges via data connection THANK YOU!

Thanks to the programming magicians and people who spread the word that you can access devices via the data connection. This is what I was looking for.

This code is actually shorter than addressing six centrifuges using the device pins.

I have not verified if the purge works but turning on/off all centrifuges does work. Since I do not expect myself to install more than 500 centrifuges I did not prevent sp going over 512.

#the script finds all centrifuges on its own #chip needs to be pulled if new centrifuges have been added define CENTRIFUGE 690945935 define minReagents 10 alias deviceCount r15 alias refID r14 alias index r13 alias deviceHash r12 alias error r11 alias reagents r10

lb r0 CENTRIFUGE PrefabHash 1 #sum off all centrifuge hashes div deviceCount r0 CENTRIFUGE #number of centrifuges s db Setting deviceCount move index 0 findDevices: get refID db:0 index #access devices by connection:0 (data), returns ReferenceId l r0 refID PrefabHash bne r0 CENTRIFUGE wrongDevice push refID #store ReferenceId in stack memory wrongDevice: add index index 1 bne sp deviceCount findDevices

enableCentrifuges: pop refID s refID On 1 bnez sp enableCentrifuges

loopInit: move sp deviceCount loop: beqz sp loopInit pop refID l error refID Error beqz error loop s refID Open 1 wait: yield l reagents refID Reagents bgt reagents minReagents wait s refID Open 0 j loop

— 0