Binding by type
One ubind, one unit. The next one gives another, and so on round the circle until they run out
ubind @polyOne line, and @unit holds a poly — one of those flying about the map. Every program about
units starts here: while @unit is empty there is nobody to command.
A bound unit is an ordinary object: sensor asks it for coordinates, health and type exactly
as it would a building.
Every call gives the next one
Section titled “Every call gives the next one”There are three polys on the map, and the program binds four times in a row. first, second
and third get different units, and fourth turns out to be the same as first: the list
closed the circle.
ubind does not “take some unit”, it walks a list. The processor has a counter — one per
unit type — and every binding moves it on by one.
That is where the main technique for working with a squad comes from: one iteration, one unit. The program binds, gives an order and ends the iteration; on the next one it gets the next unit, and so the whole squad gets its turn.
ubind @polyucontrol move 20 30 0 0 0Two lines with no loop at all drive every poly on the map — simply one at a time.
When there are no units
Section titled “When there are no units”There are no flares on the map, and ubind @flare puts emptiness into @unit. There is no
error: neither in the game nor in the example does the program stop.
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.