Skip to content

Writing it in the game

Where the program lives, what a line is made of and what the buttons around it do

easy

You don’t type a program in the game — you assemble it out of blocks. Click the processor, a row of buttons appears under it, and the pencil in that row opens the program window.

Everything happens in that window from there on. It also stands on every page of this course: the example below is that window, only with our own buttons on top.

tick 0
Set0
=
Operation1
=
Operation2
=
@counter0number
stocknullnull
doublednullnull
totalnullnull

Every line is built the same way:

  • a header — the instruction’s name on the left, the line number on the right;
  • three buttons in the header: the plus adds a new line after this one, the two pages copy the line, the cross deletes it;
  • a body — the fields you write into. A field takes both a number and a variable name: the block does not care which, and in writing there is no difference between “a value” and “a variable”.

The header colour is not decoration: it says which category the instruction comes from. Input and output are greyish pink, block control is brick, operations are lilac, flow control is turquoise, units are sandy, world ones are blue. The “Add…” menu uses the same colours, and its sections are laid out by them.

Lines are reordered by dragging them by the header, and that is the first thing worth learning: the order of the lines is the order of execution. “Move a line up” in mlog means “run it earlier”, not “make it more important”.

Instruction names and field labels have descriptions: hover the cursor or hold your finger, and a black plate appears explaining what the instruction does and what goes in the field. They work the same way on the course pages.

Not everything has one: signs like < and > have no tooltip in the game either — there is nothing to explain there.

There are four buttons under the program window, and newcomers leave three of them unopened for years.

  • “Back” closes the window. The program saves itself; there is no separate “save” button.
  • “Edit…” opens a small window with four actions: clear the program, copy it to the clipboard, paste from the clipboard and restart. It is the most useful button in the window — see the lesson “A program is text”.
  • “Variables” shows what is in the processor’s variables right now. It is the main debugging tool, and it gets the lesson “The variables window”.
  • “Add…” — a new line at the end of the program.

Above the example is a row the game does not have: run, step, “restart”, add a line, the eye and the book.

Step runs exactly one instruction. The game cannot do this: a processor is either running or switched off. For learning it is the key button — you can watch one variable change at a time.

“Restart” does exist in the game, but it is hidden: it is “Restart” inside the “Edit…” window.

The eye removes the frame around the next line: while the example is running it jumps every tick, and that flickers.

The book switches the language of the labels — more on that below.

Since version 160 the game translates the labels inside the blocks: Operation becomes a word in your own language, and so do in and and. The setting responsible is “Logic Localization” in the “Graphics” section, and it is on by default.

The book button above the example does the same thing. Press it and look at the lines: names and labels turn English, and the fields do not change by a single character.

That is the main thing to take away: the translation does not touch the language. In the block’s field, in the program’s text and in a schematic it is still sensor block1 @totalItems — in someone else’s guide and in your own game alike, whatever the setting. Only the words around the fields change.

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.