A pause in seconds
Wait this many seconds — and spend not a single instruction on the waiting
wait has one field — how many seconds to wait. Fractions are allowed: wait 0.1 is six
ticks, wait 2.5 is a hundred and fifty.
Press “run” and watch loops: one a second, not a hundred. The program does its job once
a second and keeps quiet the rest of the time.
Waiting spends no instructions
Section titled “Waiting spends no instructions”Inside, wait is simple: while the time is not up it puts the counter back on itself and
gives up the rest of the tick. On the next tick the processor hits the same line again, checks
the time and gives up the tick again.
That matters: while a program is waiting it runs nothing. The @ipt budget is not spent, and
the room in the tick goes to your other lines — or rather, will go to them once the wait is
over.
How many iterations come out
Section titled “How many iterations come out”The same one-useful-line program on a hyper processor, 60 ticks:
| Tail | Iterations per second |
|---|---|
| nothing | 1475 |
wait 0 |
59 |
wait 0.5 |
2 |
wait 1 |
1 |
The difference between the first row and the second is the price of waiting: the program stops spinning for nothing. The difference between the second and the third is set by you, and that is the next lesson.
Game time, not yours
Section titled “Game time, not yours”wait measures a pause in game ticks, and a tick is 1/60 of a second at normal speed. When the
game is sped up or lagging, the ticks run differently, and wait 1 will not be exactly
a second by the clock on the wall. For logic that is usually right: a program lives in the
game’s time.
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.