Who is driving the unit
A unit obeys whoever commanded it last. Two properties tell you who that is right now
Two processors are looking at one poly. The upper one commands, the lower one only asks — and sees somebody else’s authority from the outside.
sensor who @unit @controllerop equal own who @this@controller gives the block that is currently driving the unit. In the upper processor
own becomes a one; in the lower it stays zero, because who there is somebody else’s
processor1.
Two properties instead of one
Section titled “Two properties instead of one”| Property | What it gives |
|---|---|
@controlled |
a number: what kind of driver — a processor, a player, an order |
@controller |
an object: which block exactly, or the unit itself if logic is not driving it |
@controlled’s numbers are not made up; they have names:
| Value | Constant | What it means |
|---|---|---|
0 |
— | nobody: the unit lives by its own mind |
1 |
@ctrlProcessor |
a processor is driving it |
2 |
@ctrlPlayer |
a player is inside it |
3 |
@ctrlCommand |
a player has given it an order |
Neither of the two answers in full
Section titled “Neither of the two answers in full”The properties look like two views of one thing, but each has a blind spot of its own — which is why a real check takes them together.
Hence both lines together, and in this order:
sensor ctrl @unit @controlledjump 0 greaterThan ctrl 1 # taken by a human — leave it alonesensor who @unit @controllerjump 0 notEqual who @this # taken by another processor — likewiseAuthority is taken away in silence
Section titled “Authority is taken away in silence”Here both of them command, and each drags the poly towards its own corner. Watch own in both:
the one goes to whichever command ran last, and the unit dangles between two targets.
Ten seconds and no more
Section titled “Ten seconds and no more”Here the order is given once, and after that the program only asks. The poly reaches the
spot — and ten seconds later ctrl drops from one to zero, while who starts showing the unit
itself. The processor has let it go.
Every order refreshes the term: while ucontrol is called in a loop, the authority never runs
out. The moment the calls stop — six hundred ticks, and the unit returns to itself.
Who cannot be taken
Section titled “Who cannot be taken”Two cases where ucontrol keeps quiet however often it is called:
- a player is driving the unit. One with somebody inside is not given to logic at all;
- the unit has an order — the kind a player hands out by selecting and clicking the map.
In both cases ubind works as usual and puts the unit into @unit — but the orders never
reach it, and @controller will not say so: it goes on giving the unit itself. That leaves
@controlled: two and three mean the unit is taken by a human.
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.