Buildings by flag
A building cannot be searched for by type, but it can be searched for by role: core, turret, store, generator
ulocate building turret true @copper enemyX enemyY enemyFound enemysulocate building turret false @copper oursX oursY allyFound oursTwo lines differing by one word: the first finds an enemy turret on tile 18, the second ours on tile six. It is the third field that decides whose building to look for.
| Field | What is in it when searching for a building |
|---|---|
| first | building |
| second | the flag: what kind of building it is by role |
| third | true — theirs, false — ours |
| fourth | an item — not needed for this kind of search |
| fifth and sixth | the coordinates of what was found |
| seventh | whether it was found |
| eighth | the building itself, as an object |
Flags: a role instead of a name
Section titled “Flags: a role instead of a name”You cannot search for “a duo” or “a container” — you search for a building with the right flag. The flags are set in advance, in the game itself, and there are ten of them:
| Flag | Who carries it |
|---|---|
core |
the core |
storage |
container, vault |
generator |
anything that produces power |
turret |
any turret |
factory |
factories: smelters, presses, mixers |
repair |
repair point |
battery |
battery |
reactor |
reactor |
drill |
any drill |
shield |
force projector |
A building can carry more than one: a thorium reactor is flagged both generator and
reactor — it can be searched for either way.
The eighth field: the building itself
Section titled “The eighth field: the building itself”ulocate gives back not only coordinates but the building as an object — and that is the most
valuable part. From then on it is treated like any building:
ulocate building core false @copper x y found coresensor copperLeft core @coppersensor intact core @healthNo link to that building is needed: sensor reads unlinked blocks too. control, though, does
not — it requires a link.
A building’s coordinate is not always whole
Section titled “A building’s coordinate is not always whole”Look at storeX in the example: 10.5, although the container stands on tile ten.
That is how it should be. A block with an even side — 2×2, 4×4 — has its centre not in the
middle of a tile but on its corner, so its coordinates come out with a half. ulocate gives
exactly the building’s centre, as sensor @x does.
For ucontrol move that is even handier: the unit flies to the middle of the store rather than
to its corner.
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.