Query
A radar gives you one. Query gives you everybody who fell inside a circle or a rectangle
query circle unit null 9 6 3 0sensor everything @queries @sizeA circle of radius three around the point 9 6 turned out to hold three units: two daggers
and a flare. Their list sits in @queries.
| Field | What is in it |
|---|---|
| first | the shape: circle or rect |
| second | what to look for: unit, building, bullet |
| third | a team, or null for “anybody’s” |
| fourth and fifth | the area’s centre in tiles |
| sixth | the radius for a circle, the width for a rectangle |
| seventh | the height for a rectangle; a circle does not need it |
A rectangle is measured from its centre: query rect unit null 9 6 4 4 is a four-by-four
square centred on 9 6, not a corner at that point.
The list is read like a memory cell
Section titled “The list is read like a memory cell”@queries is neither a number nor an object but a list. Two instructions work with it:
sensor amount @queries @sizeread who @queries 0sensor @size gives the length, read an element by index counting from zero. From then on
each element is an ordinary unit or building, everything on which is read with sensor.
And that is the whole walk:
set index 0read who @queries indexsensor health who @healthop add index index 1jump 1 lessThan index amountFiltering by team
Section titled “Filtering by team”The third field is a team, and it decides who counts:
query circle unit null 9 6 3 0 # everyone: threequery circle unit @sharded 9 6 3 0 # ours only: twoEmptiness (null) means “any team”. A specific team means its units only. There is no
“everyone but mine” condition here: if you want enemies specifically, take everybody and filter
by @team yourself.
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.