Welcome to the official, although incomplete, Mindustry Logic manual.
This is both a guide and a reference for Mindustry Logic. It contains both basic and advanced information relating to the language. This manual is designed to be comprehensive to all levels of programming, and we're trying to make it understood by people who don't even know what code is.
What is Mindustry Logic?
Mindustry Logic (mlog) is a scripting language added in v6 for the purpose of introducing more advanced automation and strategy into the game. It is heavily inspired by Assembly languages, where there is only one instruction or operation at a time. This is quite unlike more popular languages such as Python, Java, or C++, where you have convenient ways to create one-liners, functions, conditional statements, loops, and classes.
The current capabilities of the language are:
- Getting information about blocks and units, including the player
- Controlling buildings and turrets
- Controlling and writing/reading information to/from units
- Displaying shapes and colors in displays
- Outputting text through message blocks
- Reading and writing information to and from memory cells
- Reading player input through switch blocks
- Mathematical operations, both unary and binary
- And much more!
What do I need before I get into Mindustry Logic?
A good thing to have beforehand is some programming experience, at least in regards to concepts and theory. This can help with understanding some of the techniques and concepts of this language. But most importantly, you need patience and an open mind, since a lot can change between updates and many things may seem daunting and complex until you try them out.
You might also want to have Google on hand if you don't understand specific programming terms used here.
Why is everyone rude in #logic on the Discord?
Most of the time it's just because the answer to your question is in very close reach, and all you need is to install this manual or read it better. All if not most of the time, all you need to do is RTFM (read this fabulous manual) thoroughly, and you will find your answer. If you're absolutely sure it isn't covered here, you are welcome to ask a question in #logic.
How to ask an effective question:
- First, try to figure it out with the help of this manual or Google. Include what you've tried and already know.
- Please DO NOT post extremely frequently asked questions such as "how do I control turret" or "how to make unit move". Again, you can find your answers here.
- Ask in detail so anybody who helps you has all the context they need to do so effectively.
We try our best not to be rude or impolite, but questions that don't go by those standards can test our patience, especially if the solution is simple and covered by the manual. It's a waste of someone's time to ask them about a question that's already written clearly in the manual.
Examples of acceptable question structure and spirit:
- "Hey after reading the manual, I can't understand what exactly a double is. Can't I just use an int?"
- "I'm having trouble with radar. It doesn't detect my player even though I'm in range of the turret. Here is my code:"
- "Why can't I print a string and a variable properly in the same print instruction?"
It's inevitable that not everybody can do that all of the time, so try your best to make your question presentable at the very least, and follow at least one of these guidelines.
How do I get the in-game manual?
There is a more comprehensive in-game manual mod that goes into detail for instructions and variables available at DeltaNedas/rtfm. Once installed you can access the instruction manual page by clicking the new book button in the processor UI, other pages are available in the full RTFM dialog.