Skip to content

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.

tick 0
Sensor0
=
in
Print Char1
char
Print2
Print3
Print Char4
char
Print Char5
char
Print Flush6
Wait7
@counter0number
coppernullnull
textBufferstring

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.

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.

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.

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.