stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 239

Day 239 of 365 · Pro · Month 9: Logistics and greenhouse

The sorter

The sorter sends every item to one of two outputs. In logic mode the chip decides: it reads OccupantHash in the input slot and sets Output.

Lesson 18 min Week 35

What you learn today

  • Mode and output
  • Check OccupantHash
  • Sorting rules

Everything comes out of the deep miner mixed up, out of the centrifuge too. Before anything goes into the furnace or into storage, it has to be sorted. The sorter is the diverter for that – and a chip tells it where to.

The sorter

StructureSorter has an input slot (0) and two outputs: slot 1 for output 1 and slot 2 for output 2. It needs power (50 W) and On. With Mode you choose who decides:

ModeNameBehaviour
0Splitalternately output 1 and 2
1Filteritems matching a filter to output 2, the rest to output 1
2Logicthe chip decides via Output

You set filters on a computer with a sorter motherboard. If filters are set, the sorter switches into filter mode by itself. Conversely, every switch to Mode 0 or 2 clears the filter list.

Which of the two openings on the device is output 1 and which is output 2 depends on the connections, not on “left” or “right”. Check it with a single test item while building, before you lay the chutes.

Output: setting the diverter

In logic mode the sorter waits until Output is set:

  • Output 0 sends the waiting item to output 1,
  • Output 1 to output 2.

Afterwards it sets Output back to −1 itself and waits for the next decision. So the chip has to decide anew for every item.

Warning

Only write Mode when it is not already 2. Every write of Mode – even with the same value – resets Output to −1 in logic mode, and only after the chip's tick. A chip that writes Mode every tick usually wipes its own decision before the sorter carries it out.

lbn tmp SORTER HASH("Erzweiche") Mode Average
beq tmp LOGIC mode_ok
sbn SORTER HASH("Erzweiche") Mode LOGIC
mode_ok:

Checking OccupantHash

What lies in the input slot is revealed by OccupantHash – the item's prefab hash. A comparison with the hash of the wanted ore directly gives 0 or 1, exactly the values Output needs:

lbns kind SORTER HASH("Erzweiche") 0 OccupantHash Average
seq target kind IRON_ORE
sbn SORTER HASH("Erzweiche") Output target

Sorting rules

One item in the slot, one decision. If nothing lies in the slot, the chip decides nothing either – otherwise an Output for the next item would be fixed before the chip has seen it:

lbns occupied SORTER HASH("Erzweiche") 0 Occupied Average
sgtz occupied occupied
beqz occupied start

sgtz turns NaN into 0: if the sorter is missing, nothing gets decided.

Tip

Two outputs are few. For three or more targets you chain sorters: the first separates ore from the rest, the second splits the rest further. One chip can control all of them, every sorter has its own name.

Exercise

Task

The sorter “Erzweiche” runs in logic mode (Mode 2 – only write it when it is not already 2). If an item lies in the input slot, the chip sends iron ore (ItemIronOre) to output 2 (Output 1) and everything else to output 1 (Output 0). If the slot is empty, it writes no Output. The light “Weichenfehler” is on when the sorter is unreachable.

Hints

Hint 1

Read Mode: if it is not LOGIC, write it once. For the light, snan on the value you read.

Hint 2

Empty slot: lbns … 0 Occupied, sgtz, beqz occupied start.

Hint 3

seq target kind IRON_ORE directly gives 0 or 1 for Output.

Quiz

4 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed the simulator exercise
  • Passed the quiz with at least 60 %

Without an account progress is saved in this browser only.

Report a mistake in this lesson

Please sign in to report. Sign in

Esc
↑ ↓ selectEnter open/ opens search anywhere