Skip to content

A high level language for Mindustry Logic (mlog) and Mindustry Schematics.

License

Notifications You must be signed in to change notification settings

cardillan/mindcode

Repository files navigation

Mindcode

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.

Mindcode Syntax

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. See Strict and Relaxed syntax.

The relaxed variant of the syntax will be eventually removed.

Latest development

The most important recent changes to Mindcode include:

  • 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

See changelog for a comprehensive list of changes.

Using Mindcode

Online

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.

Offline

Alternatively, you can download the command-line compiler and use Mindcode from within an IDE.

Mindustry Logic References

If you don't know much about Mindustry Logic, you can read more information about it here:

Unfortunately, other sources are rather dated at this moment:

Contributing

See CONTRIBUTING.

License

MIT. See LICENSE for the full text of the license.