Mindcode is a high-level programming language for Mindustry Logic. 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. The project uses lots of automated tests to make sure the produced code is correct.
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.
Tip
Mindcode currently undergoes substantial changes to the syntax. You might want to have a look at the upcoming changes that are still being deliberated. Comments and suggestions are welcome.
Please read the syntax document for a complete description of Mindcode syntax. You can also use the code examples in the web application to get familiar with Mindcode.
Important
In the 2.3.0 release, Mindcode introduces a stricter form of the syntax where semicolons and the do
/then
keywords are no longer optional. The original syntax is deprecated, but will be available for some time through the #relaxed;
directive, which can be put at the beginning of your code. Other changes to the syntax include compulsory out
keywords for output function call arguments and using the @
prefix for Mindustry built-in variables used as properties. The old syntax is still supported, but generates a warning. See Strict and Relaxed syntax for a description of all changes to the syntax.
The relaxed variant of the syntax will be eventually removed.
The most important recent changes to Mindcode include:
- Mindustry Logic 8
- Full support for the Mindustry Logic in the upcoming Mindustry version 8.
- A system library of useful functions is available when compiling for Mindustry Logic 8.
- Basic functionality
- Significant improvement in reporting error messages generated during compilation.
- 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.
- Mindcode syntax
- User-defined functions enhancements: user-defined functions may provide additional return values through output parameters, can accept variable number of arguments and can be overloaded.
- New mechanism for program parametrization.
- Improved List iteration loops supporting more than one loop variable and modification of the list elements while iterating.
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.
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:
- Mlog Documentation Sep 2024
Unfortunately, other sources are rather dated at this moment:
- Logic in 6.0 Aug 2020
- How To Use Processors in 6.0 Nov 2020
- An Overly In-Depth Logic Guide Dec 2020
See CONTRIBUTING.
MIT. See LICENSE for the full text of the license.