Links and getlink
A link is not adjacency: a block has to be connected, and only then does it get a name
A processor cannot see the blocks around it. A container pushed right up against it does not exist as far as the program is concerned — exactly like a container on the far side of the base.
To make a block appear in the program you connect it: click the processor, then the block. A circle is drawn around the processor while you do — that is its range, and there is nothing to connect beyond it. Clicking a connected block again removes the link.
Range depends on the processor
Section titled “Range depends on the processor”| Processor | Range |
|---|---|
| micro processor | 10 tiles |
| logic processor | 22 tiles |
| hyper processor | 42 tiles |
The distance is measured from the middle of the processor to the middle of the block, but half the block’s size is added to the range: a large vault’s middle is further away while its edge is nearer, and the game counts by the edge.
The name comes from the link, not the block
Section titled “The name comes from the link, not the block”A connected block gets a name like container1, cell1, display1. It is assembled from the
block’s name: the last part after a hyphen is taken, and the number is the first free one,
starting at one.
| Block | Link name |
|---|---|
container |
container1 |
memory-cell |
cell1 |
power-node |
node1 |
titanium-conveyor |
conveyor1 |
large-logic-display |
display1 |
power-node-large |
node1 |
metal-wall-2 |
wall1 |
The last two rows are a special case: if the block’s name ends with large or with
a number, the game takes the part before it. That is why a large power node is a node too,
not a large.
The number is the first free one, not the next one: remove the link to container1, then
connect a different container, and it becomes container1 again.
@links and getlink
Section titled “@links and getlink”Names are convenient while there are three links. When there are fifteen of them and they
change, the program needs to walk the list — @links and getlink are for that.
@linksis how many links the processor has right now, a number.getlinkis a building by index, starting from zero. An index out of range givesnull.
Press “step” five times. The example has two connected blocks — a container and a memory
cell — so amount becomes two, first turns out to be container1, second is cell1, and
third stays empty: there is no link number 2, and mlog has no such thing as an error.
Look at the type column in the table: first and second say building — not a number and
not text, but the block itself. sensor works with such a value and does not care whether it
came from a link name or from getlink.
When a link disappears
Section titled “When a link disappears”The block is demolished — the link becomes invalid, @links goes down, and sensor by name
starts answering null. The program meanwhile keeps running as if nothing happened: checking
whether the block is gone is your job.
Put an identical block in the same place and the link comes back with its old name. Put a different one and the name is recomputed for the new block.
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.