Skip to content

Get Flag

The other side of setflag — and the only way to learn that something happened somewhere on the map

tick 0
Get Flag0
resultflag
Jump -> 41
if
Print2
Print Flush3
Operation4
=
End5
@counter0number
alarmnullnull
checksnullnull
getflag alarm "alarm"
jump 4 equal alarm 0

The order of the fields is the reverse of what setflag accustoms you to: first where to put it, then the name. As with read and sensor — the result always comes first.

Field What is in it
first where to put the answer: 1 or 0
second the flag’s name as a string

An unset flag answers with zero, not emptiness: asking about any name is safe, and there is no need for a separate “does such a flag exist” check.

getflag and setflag are world-processor instructions, and an ordinary one will not run them. But a flag still reaches the map: through objectives.

A script on a map usually looks like this:

  1. the world processor watches what happens and raises a flag;
  2. the map’s objective, set to that flag, is marked complete;
  3. the player sees a tick in their task list.

World processors also talk to one another with flags — that is cheaper and more reliable than a memory cell: no link is needed and no building can be destroyed.

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.