Skip to content

Configuring a block

A sorter, an unloader and a factory are configured with an item — and logic can change that setting on the fly

Some blocks in the game are configured by clicking them and picking an item: a sorter, an unloader, an item source, a unit factory. Whatever is picked is the block’s configuration — and logic can change it.

tick 0
Sensor0
=
in
Sensor1
=
in
Select2
= if
then else
Control3
set of
to
Sensor4
=
in
@counter0number
copperLeftnullnull
leadLeftnullnull
itemnullnull
settingnullnull

The program looks at which of the two is scarcer in the store and configures the sorter for that item. Copper 40, lead 25 — so the sorter settles on lead.

Only as an object, and only for those that have a configuration

Section titled “Only as an object, and only for those that have a configuration”
control config sorter1 @lead

The third field is a content object: @lead, @titanium, @poly. Not a number and not a string.

Not every block has a configuration. The ones logic can drive are those configured with content:

Block Configured with
sorter, inverted sorter an item
unloader, ductular unloader an item
duct router and overflow-style routers with a filter an item
item source, liquid source an item or a liquid
ground, air and naval factories a unit type
tank, ship and mech assemblers a unit type
constructor and large constructor a block
payload unloader, payload source a block or a unit type

There are about twenty such blocks in all. A container, a drill and a turret are not on the list: they have nothing to configure, and the command passes them by.

Reading the configuration — with the same sensor

Section titled “Reading the configuration — with the same sensor”
sensor setting sorter1 @config

It answers with an object — the one that was put there — or emptiness, if the block has no configuration at all. It is convenient to compare straight with a constant: jump 8 equal setting @lead.

  • One sorter instead of five. The program sees what is running short and reconfigures it on the fly — the line carries the scarce thing by itself.
  • An unloader on demand. The core hands out exactly what a factory is asking for.
  • A factory for the task at hand. One factory makes polys one moment and daggers the next, depending on what is needed right now.

Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.