Skip to content

Switching on and off

The one command that works on any block: switch it off and switch it back on

A switched-off block does not work: a drill does not drill, a factory does not produce, a conveyor does not carry. Logic uses this constantly — it is its main way of interfering with a base.

tick 0
Sensor0
=
in
Operation1
=
Control2
set of
to
Sensor3
=
in
@counter0number
coppernullnull
lownullnull
runningnullnull

The program watches the store and keeps the drill on while there is less than a hundred copper. Press “run” and wait: as soon as copper reaches 100, running becomes zero and the drill stops.

The line reads as “enable the block on a condition”

Section titled “The line reads as “enable the block on a condition””
control enabled drill1 low

The third field is not “on” and not “off” but a number: zero switches off, any other value switches on. So what usually goes in there is the result of a comparison:

op lessThan low copper 100
control enabled drill1 low
sensor running drill1 @enabled

The @enabled property is read on any block and answers with a one or a zero. That is handy for debugging: if a block is not working while the program is sure of the opposite, one line settles the question.

tick 0
Read0
=
Control1
set of
to
Control2
set of
to
Sensor3
=
in
Sensor4
=
in
@counter0number
theirsnullnull
mineRunsnullnull
theirsRunsnullnull

There are two drills on the map. The first is linked to our processor, the second to a neighbouring one; ours fetches it by the neighbour’s link name and commands both the same way.

Press “run”: mineRuns becomes zero and theirsRuns stays one. The building is real — sensor reads it perfectly well — but the order does not reach it.

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.