Skip to content

Another processor's variables

A cell for exchanging values isn't always needed: a neighbour's variable can be taken straight from it, by name

A processor is a block like a cell, and it is read the same way. Only the address is not a slot number but a variable’s name in quotes:

read theirLoops processor1 "loops"
tick 0
Read0
=
Read1
=
Sensor2
=
in
Print3
Print4
Print5
Print6
Print Flush7
@counter0number
loopsnullnull
enemyStorenullnull
coppernullnull

There are two processors on the map. The upper one simply counts its iterations; the lower one — the one whose program is shown — fetches that counter by name and prints it. There is no memory cell between them at all.

Address What you get
"loops" — the neighbour has such a variable its value, a number or an object
"container1" — no such variable, but there is a link with that name the building connected to the neighbour
"nonsense" — neither one nor the other emptiness
0, 1, … as a number the neighbour’s link by index — the same as its getlink

The second line of the example is exactly that: read enemyStore processor1 "container1". The lower processor has no link to the store of its own, yet it can still ask it how much copper it holds — the building is taken from the neighbour.

@this is the processor itself, and it can be read the same way:

read copy @this "count"
read block @this 0

The first is a copy of your own variable, the second your own link by index — that is, getlink in other words. There is no particular use in the first; the second is occasionally handier.

The check sits in the block itself, and it is short: it answers its own team and only non-world processors.

  • another team’s processor — emptiness, even if it stands right there with a link;
  • a world processor answering an ordinary one — emptiness: a privileged block answers only a privileged one;
  • a world processor is answered by everybody, other teams included.

Writing obeys the same rules: what cannot be read cannot be overwritten either.

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.