Mindcode is a high-level programming language for Mindustry Logic. Many language features are provided, including variable declaration, arrays, conditional statements and loops, functions, modules, system library etc. Mindcode generates fairly well optimized mlog code, utilizing available instruction space to make the resulting code faster. It comes with a web app and a command-line compiler, provides means for integration both with various IDEs and Mindustry itself.
Schemacode, an extension built over Mindcode, is a specialized definition language designed for creating a complete Mindustry schematic from a text file. Schematics builder compiles these definition files directly into Mindustry schematics, either into binary .msch
file, or into the text representation. Processors can be included in these schematics, complete with the code (specified either in Mindcode or mlog) and linked blocks.
Please refer to the documentation for a complete description of Mindcode syntax. You can also use the code examples in the web application to get familiar with Mindcode.
You can also visit golem, a collection of more complex Mindcode and Schemacode scripts.
See issues for open bugs and possible workarounds.
Note
Deprecated functionalities from Mindcode 2.x were removed. The system for specifying language version targets has been changed.
The most important recent changes to Mindcode include:
- Language features
- External and internal arrays (@counter arrays).
- Expressions in string interpolation:
print($"Sum: ${a + b}.");
- Support for color literals:
%00ffff80
- Prefix/postfix increment/decrement operators:
i++
,--j
- Redefined strict and relaxed syntax modes
- Optional variable declaration (compulsory in strict syntax)
- Basic functionality
- Significant improvement in reporting error messages generated during compilation.
- A built-in library of system functions.
- Ability to inject the mlog code to Mindustry processors via the Mlog Watcher mod.
- Support for running the compiled mlog code in an emulated processor.
- Tool for partial decompilation of an existing mlog code into Mindcode.
- Mindustry Logic 8
- Almost complete support for the Mindustry Logic in the upcoming Mindustry version 8. The Logic ability to read/write variables in remote processors is not yet supported.
- New
printchar
instruction.
See changelog for a comprehensive list of changes.
Mindcode is available at http://mindcode.herokuapp.com/. Write some Mindcode in the Mindcode Source Code text area, then press the Compile button. The Mindustry Logic text area will contain the mlog version of your Mindcode. Copy the mlog code into the clipboard. Back in Mindustry, edit your processor, then use the Edit button in the Logic UI. Select Import from Clipboard. Mindustry is now ready to execute your code.
You can also use the Compile and Run button to execute the compiled code right away on an emulated processor. The output produced by print
instructions in your code will be displayed. Very limited interaction with the Mindustry World is supported.
Tip
Mindcode performs a variety of different optimizations. The mlog code it produces may bear little resemblance to the original source code at a first glance.
Alternatively, you can download the command-line compiler and use Mindcode from within an IDE.
If you don't know much about Mindustry Logic, you can read more information about it here:
- Yruei's Mlog Documentation (last updated Feb 2025)
You can also get help on these Discord servers:
See CONTRIBUTING.
MIT. See LICENSE for the full text of the license.