Logic Sorter
More actions
| File:StructureLogicSorter.png | |
| Operation | |
|---|---|
| Power Usage | 5W |
| Prefab Hash | 873418029 |
| Prefab Name | StructureLogicSorter |
| Construction | |
| Placed with | Kit (Sorter) |
| Placed on | Small Grid |
| Paintable | No |
| Stage 1 | |
| Deconstruction | |
| Deconstructed with | Hand Drill |
| Item received | Kit (Sorter) |
Description
Contains an Internal Memory which is assessed to check whether something should be sorted. When an item is in the Import slot Slot, the stack is checked and if result is true the thing is moved to the Export2 slot slot, otherwise it is moved to the Export slot slot. The Mode is used in how the stack is assessed, by default the mode is ALL, so every instruction in the stack would need to return true.
- Stationpedia
Logic sorter is similar in almost every way to the previous sorter but has a internal memory that can be configured with logic and bit shifting to sort items passing through. When an item enters the import slot, it is checked against the evaluation instructions in memory. If the Mode is 0(All) then every evaluation must return true for the item to be sent to the export 2 slot. If the mode is 1(Any) then as long as one of the evaluations returns true, the item matches and will be sent to the export 2 slot.
Sorter Instructions
Check the in game Stationpedia [F1 on your keyboard] for formatting and instruction sizes to determine how to populate the memory. Be warned that the stationpedia fails to document the endianness (bit 0 is the least significant bit). While the stationpedia does document that the Logic Sorter has 256 bytes of memory, it is addressed as 32 x 8-byte (64-bit) numbers.
If you wish your sorter to send Steel Ingots to the second output you should place the value $D8F8AF8D01 ( = 931885190401 decimal ) into memory 0. More complicated programs will have to consider whether they want to use Mode 0 (match All), Mode 1 (match Any), or Mode 2 (match None).
It is more readable to calculate the instructions using IC10 like this:
alias Sorter d0 define SteelIngotHash HASH("ItemSteelIngot") #= -654790771, or $D8F8AF8D s Sorter Mode 1 #Any clr Sorter #Erase any stale instructions in logic sorter memory move r0 FilterInstruction.PrefabHashEquals #Create a new sorting instruction ins r0 SteelIngotHash 8 32 #Insert prefab hash into our sorting instruction put Sorter 0 r0 #Write our sorting instruction to logic sorter memory
| Sorter Instruction | Opcode [0..7] | Argument 1 | Argument 2 | Description |
|---|---|---|---|---|
| [Undocumented] NOP | 0 | Unused [8..63] | Skip processing this instruction regardless of what the rest of the stack address contains.
Can be used to store data for inter-device communication. Not treated as an evaluation instruction. | |
| FilterPrefabHashEquals | 1 | PrefabHash [8..39] | Evaluates the Hash of item in import slot to the set hash and returns true if equal to the hash in Argument 1 | |
| FilterPrefabHashNotEquals | 2 | PrefabHash [8..39] | Evaluates the Hash of item in import slot to the set hash and returns true if not equal to the hash in Argument 1. | |
| FilterSortingClassCompare | 3 | Conditional Operation [8..15] | Sorting Class [16..31] | Evaluates a comparison of the conditional operation in Argument 1 between the sorting class of an object in input slot and the class contained in Argument 2, returning the result. |
| FilterSlotTypeCompare | 4 | Conditional Operation [8..15] | Slot Type [16..31] | Evaluates a comparison of the conditional operation in Argument 1 between the slot type of an object in input slot and the slot type contained in Argument 2, returning the result. |
| FilterQuantityCompare | 5 | Conditional Operation [8..15] | Quantity [16..31] | Evaluates a comparison of the conditional operation in Argument 1 between the quantity of an object in input slot and the quantity contained in Argument 2, returning the result.
Special cases include: - Credit Cards (Amount of currency) - Batteries (Charge Ratio, as a 0-1 value making rounding useless) - Consumables (Remaining percentage) While there is a support for a Quantity field in gas mixtures (returning total mols), gas/liquid canisters don't have an override using it as of the Power Line Update (Q3 2026). |
| LimitNextExecutionByCount | 6 | Count [8..39] | Ensures the next evaluation instruction will only return true a specified number of times.
Each time it returns true, Count decrements by 1. Once count reaches zero, future executions of the next evaluation instruction always return false regardless of their result. Can be used to count how many items fit the sorting criterion. If multiples of this instruction are present before the next evaluation instruction, only the last one is decremented. Not treated as an evaluation instruction. | |
| [Undocumented] False | 7..255 | Always return a false. Treated as an evaluation instruction. |
| Conditional Operation (CONDOP) | Value | Pre-shifted |
|---|---|---|
| Equals | 0 | 0 ($000) |
| Greater | 1 | 256 ($100) |
| Less | 2 | 512 ($200) |
| NotEquals | 3 | 768 ($300) |
| Slot Type | Sorting Class | Value | Pre-Shifted |
|---|---|---|---|
| SlotType.None | SortingClass.Default | 0 | $000000 |
| SlotClass.Helmet | SortingClass.Kits | 1 | $010000 |
| SlotClass.Suit | SortingClass.Tools | 2 | $020000 |
| SlotClass.Back | SortingClass.Resources | 3 | $030000 |
| SlotClass.GasFilter | SortingClass.Food | 4 | $040000 |
| SlotClass.GasCanister | SortingClass.Clothing | 5 | $050000 |
| SlotClass.Motherboard | SortingClass.Appliances | 6 | $060000 |
| SlotClass.Circuitboard | SortingClass.Atmospherics | 7 | $070000 |
| SlotClass.DataDisk | SortingClass.Storage | 8 | $080000 |
| SlotClass.Organ | SortingClass.Ores | 9 | $090000 |
| SlotClass.Ore | SortingClass.Ices | 10 | $0A0000 |
| SlotClass.Plant | 11 | $0B0000 | |
| SlotClass.Uniform | 12 | $0C0000 | |
| SlotClass.Entity | 13 | $0D0000 | |
| SlotClass.Battery | 14 | $0E0000 | |
| SlotClass.Egg | 15 | $0F0000 | |
| SlotClass.Belt | 16 | $100000 | |
| SlotClass.Tool | 17 | $110000 | |
| SlotClass.Appliance | 18 | $120000 | |
| SlotClass.Ingot | 19 | $130000 | |
| SlotClass.Torpedo | 20 | $140000 | |
| SlotClass.Cartridge | 21 | $150000 | |
| SlotClass.AccessCard | 22 | $160000 | |
| SlotClass.Magazine | 23 | $170000 | |
| SlotClass.Circuit | 24 | $180000 | |
| SlotClass.Bottle | 25 | $190000 | |
| SlotClass.ProgrammableChip | 26 | $1A0000 | |
| SlotClass.Glasses | 27 | $1B0000 | |
| SlotClass.CreditCard | 28 | $1C0000 | |
| SlotClass.DirtCanister | 29 | $1D0000 | |
| SlotClass.SensorProcessingUnit | 30 | $1E0000 | |
| SlotClass.LiquidCanister | 31 | $1F0000 | |
| SlotClass.LiquidBottle | 32 | $200000 | |
| SlotClass.Wreckage | 33 | $210000 | |
| SlotClass.SoundCartridge | 34 | $220000 | |
| SlotClass.DrillHead | 35 | $230000 | |
| SlotClass.ScanningHead | 36 | $240000 | |
| SlotClass.Flare | 37 | $250000 | |
| SlotClass.Blocked | 38 | $260000 | |
| SlotClass.SuitMod | 39 | $270000 | |
| SlotClass.Crate | 40 | $280000 | |
| SlotClass.Portables | 41 | $290000 | |
| SlotClass.RocketPayload | 42 | $2A0000 | |
| SlotClass.AutoInjector | 43 | $2B0000 |
MSB LSB 6666555555555544444444443333333333222222222211111111110000000000 3210987654321098765432109876543210987654321098765432109876543210 FilterPrefabHashEquals ########################( PREFAB_HASH)( 1) FilterPrefabHashNotEquals ########################( PREFAB_HASH)( 2) FilterSortingClassCompare ################################( SORTING_CLASS)(CONDOP)( 3) FilterSlotTypeCompare ################################( SLOT_TYPE)(CONDOP)( 4) FilterQuantityCompare ################################( QUANTITY)(CONDOP)( 5) LimitNextExecutionByCount ########################( COUNT)( 6)
Sorting Modes
The logic sorter has 3 operating modes: All(0), Any(1) and None(2). All modes scan the sorter's stack memory linearly from the beginning while there's something present in the sorter's input slot. If the output port the item is routed to is blocked, the item stays in the input slot and is evaluated again, rapidly decrementing "Limit Next Execution by Count" instructions if the evaluation following them returns true. If any of those are used in the filter's stack memory and relied on, care should be taken to ensure both output ports are free at all times.
Mode All moves the item to the sorted output port if at least one sorting evaluation was performed and all evaluations return true, skipping evaluations past the first that returns false.
Mode Any moves the item to the sorted output port if at least one sorting evaluation was performed and at least 1 sorting evaluation, skipping evaluations past the first that returns true.
Mode None moves the item to the sorted output port if at least one sorting evaluation was performed and all evaluations return false, skipping evaluations past the first that returns true.
As all modes require at least one sorting evaluation instruction to be executed in order to send items to the sorted output port, an unprogrammed logic sorter will send all items to the unsorted output.
Data Network Properties
These are all Data Network properties of this device.
Data Parameters
These are all parameters that can be written with a Logic Writer, Batch Writer, or Integrated Circuit (IC10), and can be read with a Logic Reader, Batch Reader, or Integrated Circuit (IC10).
| Parameter Name | Data Type | Access | Value | Description | ||
|---|---|---|---|---|---|---|
| Power | Boolean | Read
|
0 | Unpowered | Can be read to return if the Logic Sorter is correctly powered or not, set via the power system, return 1 if powered and 0 if not | |
| 1 | Powered | |||||
| Mode | Integer | Read Write
|
0 | All | The mode of the Logic Sorter. | |
| 1 | Any | |||||
| 2 | None | |||||
| Error | Boolean | Read
|
0 | 1 if device is in error state, otherwise 0 | ||
| 1 | Error | |||||
| Lock | Boolean | Read Write
|
0 | Unlocked | Disable manual operation of the Logic Sorter. | |
| 1 | Locked | |||||
| On | Boolean | Read Write
|
0 | Off | The current state of the Logic Sorter. | |
| 1 | On | |||||
| RequiredPower | Integer | Read
|
||||
| ClearMemory | Integer | Write
|
||||
| ExportCount | Integer | Read
|
||||
| ImportCount | Integer | Read
|
||||
| PrefabHash | Integer | Read
|
||||
| ReferenceId | Integer | Read
|
||||
| NameHash | Integer | Read
|
||||
Data Slots
These are all parameters, that can be read with a Slots Reader. The outputs are listed in the order a Slots Reader's "VAR" setting cycles through them.
| Number | Name | Description |
|---|---|---|
| 0 | Import | Import slot. |
| 1 | Export (reject) | Export slot. |
| 2 | Export (accept) | Export slot. |
| 3 | Data Disk | Diskslot |
| Name | Data Type | Description |
|---|---|---|
| MaxQuantity | Integer | Returns maximum stacksize. |
| Damage | Integer | Item durability in percent. |
| Class | Integer | Item class ID for slot type comparison. |
| SortingClass | Integer | Class group of items. |
| Quantity | Integer | Size of item stack. |
| PrefabHash | Integer | Returns ItemHash of item in slot. |
| Occupied | Boolean | Returns whether the slot occupied. (0 for no, 1 for yes). |
| OccupantHash | Integer | Returns ItemHash of item in slot. |