Print Char
One character at a time — but any of them: an arrow, a box-drawing line or the copper icon
printchar appends one character to the buffer. Not a string, not a number — exactly one
character, given by its code.
Press “run”. Under the message block you get the copper icon, the number 120 and an upward
arrow: the icon came from printchar @copper, the arrow from printchar 8593.
A character by code
Section titled “A character by code”The number is a character’s code in UTF-16: printchar 65 gives A, printchar 97 gives a,
printchar 32 gives a space. A fractional number is truncated down to a whole code.
Next to the field in the block there is a pencil: it opens a table of printable characters from 32 to 126, so you do not have to hunt for codes on the internet. Anything above that is typed as a number.
A content character is an icon
Section titled “A content character is an icon”printchar @copper puts the copper character into the buffer, and in the caption it looks like
an icon rather than letters. Liquids, blocks and unit types work the same way.
The trick behind it: every item has a character code of its own, but there is no glyph for it
in the font — the game draws a picture from the atlas in its place. That is why an icon cannot
be typed on a keyboard, and printchar is the only way to get one.
What it is for
Section titled “What it is for”| Task | How |
|---|---|
| an item’s icon in a caption | printchar @copper |
| an arrow or a tick | printchar 8593, printchar 10003 |
| a line break | easier as a string, print "\n" |
| a long text | not needed: that is print |
A board with icons reads noticeably faster than one with words — especially when there are several items and the line updates on the fly.
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.