Set Rate
A processor always runs at its own speed. setrate is the only way to change it, and it is almost always changed downwards
Every processor has its own speed — how many instructions it gets through per tick. It lives in
@ipt and is written in the block’s stats:
| Block | Instructions per tick |
|---|---|
| Micro processor | 2 |
| Logic processor | 8 |
| Hyper processor | 25 |
| World processor | 8, up to 1000 |
A hyper processor at full speed: in one second a five-line program gets through about 295
iterations. That is how many times a second the sensor is read, the display is redrawn and
everything written in it is recomputed.
setrate changes the speed on the fly
Section titled “setrate changes the speed on the fly”The same program with one new line at the top:
setrate 1Now @ipt is one, and in the same second the program gets through 14 iterations instead of
295. It does exactly the same thing, only twenty times less often.
It cannot be raised above its own ceiling
Section titled “It cannot be raised above its own ceiling”Here a micro processor is told to work at a thousand instructions per tick, and speed stays
a two all the same.
The number in setrate is clamped to the range from one to this block’s limit, and for an
ordinary processor that limit is its own speed. A micro processor cannot be overclocked into
a hyper; it can only be slowed down.
What it is for at all
Section titled “What it is for at all”The honest answer: for the world processor. Eight instructions per tick is not much for
a script that walks units, counts waves and talks to the player — and setrate 1000 gives it
over a hundred times more.
Ordinary processors got the instruction along the way: before version 160 it was privileged and not available to them at all. There is almost no use for slowing down: the game handles hundreds of processors calmly, and speeding a map up this way will not work either — an ordinary processor cannot go above its own rate, and there is no reason to take it below.
The one place it is occasionally useful is watching a program work: at setrate 1 you can
see the counter walking the lines. In the game people rarely look at that, while in this
course’s examples the step button does exactly the same thing.
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.