Content constants
An item, a liquid, a block and a unit are values like a number: they go into variables and get passed to instructions
@copper is not a number and not a text. It is copper itself: the same item that sits in
a container and rides a conveyor. The game creates such a constant for every thing it has.
| What | How many | Examples |
|---|---|---|
| items | 20 | @copper, @silicon, @thorium |
| liquids | 11 | @water, @slag, @cryofluid |
| blocks | 262 | @router, @vault, @duo, @air |
| unit types | 56 | @poly, @mono, @flare |
Names are written the way the thing is called in the game, in English and with hyphens:
@surge-alloy, @phase-fabric, @titanium-conveyor.
They go into variables
Section titled “They go into variables”Press “step” five times.
In the table item, block and unit have the type content — not a number, not a text,
but a thing. No arithmetic comes of them: copper cannot be added to a router, but they can be
passed where a thing is expected.
Where that comes in handy:
sensor— ask a container how much copper it holds;control config— set a sorter to the item you want;ubind— take control of a unit of the right type;draw image— draw a thing’s icon on a display.
One name, two roles
Section titled “One name, two roles”The example’s last line is sensor amount container1 item, and item holds @copper.
The answer: 120, the amount of copper in the container.
This is worth pausing on. @copper in the property field means “how much copper”, and
@copper in the value field means “copper itself”. The name is one, and the role depends on
where it was put — and that is not confusion but how the language is built: sensor looks at
what it was handed and answers differently to a thing and to a property like @health.
To sensor there is no difference between @copper typed straight into the field and
@copper arriving from a variable. So items can be walked through the same way: put them into
a memory cell and ask about them in turn.
@this and its neighbours
Section titled “@this and its neighbours”A separate little pile of constants is about the processor itself:
| Name | What it is |
|---|---|
@this |
the processor’s own building, of type building |
@thisx, @thisy |
its coordinates in tiles, numbers |
@links |
how many links it has |
@ipt |
how many instructions it runs per tick |
@this is a building, like container1: you can ask it for properties and pass it where
a block is expected. In the example it sits in the variable self, and the table shows the
processor’s name.
When a name is not enough
Section titled “When a name is not enough”Sometimes an item is needed by index rather than by name: to walk all twenty without writing
each one out. There is a separate instruction for that — lookup — which fetches a thing by its index in the game.
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.