stationeers_ic10/auto_item_sorter.ic10

54 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2023-03-30 14:40:34 +00:00
# Controls Sorters to sort items based on hash.
# Reads item-hashes from stack to decide if it
# should be split off or passed on.
# Connect one Sorter to each screw on the IC.
2023-01-22 15:42:07 +00:00
alias counter r0
move counter 0
alias hash r1
alias SlotOccupied r2
alias InputItem r3
alias IsItem r4
define INPUTSLOT 0
2023-03-30 14:40:34 +00:00
# Replace hashes below with the ones you need.
2023-01-22 15:42:07 +00:00
push 1758427767 # Iron
push -1348105509 # Gold
push -1516581844 # Uranium
push -707307845 # Copper
push 1724793494 # Coal
push -916518678 # Silver
2023-01-22 15:42:07 +00:00
#push 1830218956 # Nickel
2024-01-13 22:01:42 +00:00
#push -190236170 # Lead
2023-01-22 15:42:07 +00:00
#push 1103972403 # Silicon
2024-01-13 22:01:42 +00:00
#push -983091249 # Cobalt
2023-01-22 15:42:07 +00:00
start:
2023-03-30 14:40:34 +00:00
# Loops over screws to instruct attached Sorters,
# loops over all sorters every tick.
2023-01-22 15:42:07 +00:00
bdseal dr0 sort
add counter counter 1
bgt counter 5 reset
j start
sort:
2023-03-30 14:40:34 +00:00
# Compares Sorter input-slot with hash in stack
2023-01-22 15:42:07 +00:00
move sp counter
add sp sp 1
peek hash
s dr0 Mode 2
ls SlotOccupied dr0 INPUTSLOT Occupied
beqz SlotOccupied ra
ls InputItem dr0 INPUTSLOT OccupantHash
2023-02-06 13:21:09 +00:00
seq IsItem InputItem hash
2023-01-22 15:42:07 +00:00
s dr0 Output IsItem
j ra
reset:
2023-04-01 14:57:11 +00:00
# Resets counter to zero so we can loop over again
2023-01-22 15:42:07 +00:00
move counter 0
yield
j start