What prints as what
Anything can be printed — and almost everything turns into text differently from what you expect
print takes any value, and the buffer takes only text. So a conversion happens somewhere in
between, and its rules are worth knowing: half of all strange captions on displays come from
here.
Press “step” seven times. The buffer holds copper container null 0.5.
The conversion rules
Section titled “The conversion rules”| What is printed | What lands in the buffer |
|---|---|
| a number less than 0.00001 away from a whole one | the whole number, no fraction: 120 |
| any other number | as it is: 0.5, 3.25 |
| a string | the string itself, without the quotes |
| an item, liquid, block or unit type | its English name: copper, titanium-conveyor |
| a building | its block’s name: container, not container1 |
| a unit | its type’s name: poly |
| a team | the team’s name: sharded |
| emptiness | the word null |
A building prints as its type
Section titled “A building prints as its type”That is the first thing that surprises people. print container1 gives container, not
container1.
The reason is simple: a link name belongs to the processor, not to the block. The building itself has no such name at all — it is your note in your program, and a neighbouring processor may call the same container something else. There is nothing to print but the block’s type. About link names, see the lesson “Links and getlink”.
Emptiness prints as a word
Section titled “Emptiness prints as a word”print of null puts four letters into the buffer: null. Neither emptiness nor zero — the
word itself.
Numbers print as in the variables table
Section titled “Numbers print as in the variables table”The rule and the threshold are the same: 0.00001. If a number is less than that away from a whole one it prints whole; more, and it prints in full, every digit after the point included.
The threshold is not invented: it is written into the game itself, and the same hundred thousandth decides how a number is shown in the variables window.
One consequence spoils boards: op div share 1 3 prints as 0.3333333333333333. Rounding is
up to you — op round, op floor or a multiply and a divide — and that is the lesson
«Whole numbers and precision».
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.