alias printer d0 alias sorter d1 alias vend d2 alias button d3 alias ingothash r9 define INGOTCLASS 19 setup: s printer ClearMemory 1 move ingothash -1 j scan #scan required materials and update ingothash for what is required. start: yield s db Setting ingothash l r0 printer ImportCount select ingothash r0 -1 ingothash # if something got imported, clear ingothash l r0 button Setting select ingothash r0 -1 ingothash # if the reset button got pushed, clear ingothash yield bne ingothash -1 start # if ingothash is not clear, we are still waiting, so loop around for another check scan: # we must figure out what is required by the recipe s db Setting -1 l r0 printer Open bgtz r0 start # if the printer is Open, then it is ejecting all ingots, so we should not load anything until it is closed. s db Setting 0 lr r0 printer Required HASH("Astroloy") select ingothash r0 412924554 ingothash lr r0 printer Required HASH("Constantan") select ingothash r0 1058547521 ingothash lr r0 printer Required HASH("Copper") select ingothash r0 -404336834 ingothash lr r0 printer Required HASH("Gold") select ingothash r0 226410516 ingothash lr r0 printer Required HASH("Inconel") select ingothash r0 -787796599 ingothash lr r0 printer Required HASH("Iron") select ingothash r0 -1301215609 ingothash lr r0 printer Required HASH("Nickel") select ingothash r0 -1406385572 ingothash lr r0 printer Required HASH("Silicon") select ingothash r0 -290196476 ingothash lr r0 printer Required HASH("Silver") select ingothash r0 -929742000 ingothash lr r0 printer Required HASH("Steel") select ingothash r0 -654790771 ingothash lr r0 printer Required HASH("Solder") select ingothash r0 -82508479 ingothash lr r0 printer Required HASH("Electrum") select ingothash r0 502280180 ingothash lr r0 printer Required HASH("Invar") select ingothash r0 -297990285 ingothash lr r0 printer Required HASH("Stellite") select ingothash r0 -1897868623 ingothash lr r0 printer Required HASH("Hastelloy") select ingothash r0 1579842814 ingothash # if nothing is required, then ingothash will be -1; otherwise it will be the has of the ingot. beq ingothash -1 start # need something, request it s printer ClearMemory 1 # so we can detect when it gets loaded into the printer # rig the sorter clr sorter s sorter Mode 1 put sorter 0 262 # (1<<8) | 6 means LimitNextExecutionByCount 1 sll r0 ingothash 8 or r0 r0 SorterInstruction.FilterPrefabHashEquals put sorter 1 r0 s vend RequestHash ingothash yield j start # This script examines the recipe selected in a printer/fabricator and # queries the ingots required. If any are not satisfied by the # internal inventory, it requests those ingots from a venting machine, # and configurs a sorter to route one ingot stack to the printer. |
MIPS is the programming language used by IC (integrated circuits) in the game Stationeers. Stationeering web site has a MIPS emulator with syntax highlighting and error detection.