Sync
In a single-player game it does nothing. On a server it is the only way to show everybody the same number
sync countOne variable in one field — and its value travels to everybody playing on this map.
What it is for on a server
Section titled “What it is for on a server”On a server the map is computed once — on the server. Clients see a copy of it, and in that copy processors’ variables are empty: the server does not broadcast them, because there are hundreds of them and they change every tick.
Usually that is not needed: a client sees blocks, units and messages. But if a script wants
a client to read a value — a player’s display drawing a score from a processor’s variable,
say — the value has to be broadcast explicitly. That is what sync does.
Twenty times a second, no more
Section titled “Twenty times a second, no more”Every variable has its own timer: it can be sent once every 50 milliseconds. Anything a program tries to send more often simply is not sent — no error and no queue.
Which to choose: sync or a flag
Section titled “Which to choose: sync or a flag”sync |
a global flag | |
|---|---|---|
| what it carries | any value | “yes” or “no” |
| to whom | every client | processors and the map’s objectives |
| how often | 20 times a second per variable | no limit |
Flags are about a script’s logic, sync is about what the player sees. A number on a display,
a countdown to a wave, a team’s score: everything a client reads from a processor’s
variable needs broadcasting.
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.