Spawn Unit
A unit appears whole and at once — with no factory, no resources and no queue
spawn @dagger 9 5 90 @sharded freshA dagger appears on tile 9 5 — finished, at full health, with no factory at all. In the
example the program does this until there are three of them and then stops.
| Field | What is in it |
|---|---|
| first | the unit type: @dagger, @poly, @flare |
| second and third | coordinates in tiles |
| fourth | rotation in degrees: 90 is up, 0 is right |
| fifth | the team: @sharded, @crux, @derelict |
| sixth | where to put the created unit |
The sixth field is the most useful: the unit arrives as an object and can be worked with straight away. Not with every instruction, though:
spawn @dagger 9 5 90 @sharded freshubind freshucontrol move 20 5 0 0 0A world processor manages such a binding even to an enemy unit — that is its privilege.
There is no counter here
Section titled “There is no counter here”So spawning is always limited by something:
- count how many there already are. As in the example:
queryover an area,sensor @size, and spawn only if there are few; - do it once. A flag variable or a global flag: created, recorded, then checked;
- by time.
@timeand a comparison with a deadline: a wave every half a minute.
query circle unit @sharded 9 5 5 0sensor amount @queries @sizejump 0 greaterThanEq amount 3spawn @dagger 9 5 90 @sharded freshFour lines, and the map always has exactly three daggers: one dies and another takes its place.
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.