Instructions

9/2/2025, 3:43:01 AM


Read

Read a value from a cell

alt

resultis your variable name
cell1is where to get the value from, a building reference, “bank{number}” for Banks0 is the cell’s address. like said above, cells can store up to 64 values, this means there are only 64 addresses, starting at0, meaning0-63
Example: there is a value at 0 incell1that is10, thenresultvariable will be10

Write

Write a value to a cell

alt

Essentially the same with read but it writes instead
Example: the result variable is 10, then it will write 10 to cell1 at #0
Can also be directly written using a number instead of a variable.

Draw

Adds a command to the draw buffer

  • Clear
    Sets the entire screen to a specific color

alt

RGB stands for Red,Green,Blue
Value can be from 0 (dimmest) to 255 (brightest)
Example: 255, 255, 255 is White

  • Color
    Sets the color of the next upcoming draw isntruction

alt

RGBA stands for Red,Green,Blue,Alpha
To put it simply Alpha is Opacity, it is how opaque the next draw instruction will be
0 is 0% and 255 is 100% opaque
Value can be from 0 (dimmest) to 255 (brightest)

  • col
    Same as color, but use hex color code instead of RGB color code
    Usually used with the Pack Color instruction

  • Stroke
    Sets the line width for any upcoming draw operationsns

  • Line
    Draws a line from one coordinates to another coordinates

alt

x, y is the first set of coordinates
x2, y2 is the second sets of coordinates

  • Rect
    Draw a rectangle at the specified coordinates with the bottom left of the rectangle as its originn

alt

x, y is the rectangle coordinates
width and height are the rectangle width and height

  • Line Rect
    Same as rect, but only draws the outline of the rectangle

  • Poly
    Draw a polygon with its center as its origin

alt

x, y is the polygon coordinates
sides is the number of sides the polygon will have
radius is the radius of the polygon
rotation will rotate the polygon, in degrees

  • Line Poly
    Same as poly, but only draws the outline of the polygon

  • Triangle
    SDraws a triangle with 3 different sets coordinates as its vertices

alt

x, y is the first sets of coordinates
x2, y2 is the second sets of coordinates
x3, y3 is the second sets of coordinates

  • Image
    Draws an image of something from the game with content name, such as @dagger or @copper with its center as its origin,
    if it draws a picture of (oh no) that means whatever you're trying to draw either doesn't exist or not supported, the only work around is drawing it manually, though the Bleeding Edge version supports more content

alt

x, y is the of coordinates
image is what image it will draw, you put object name here, like @dagger
size is the size of the image
rotation will rotate the image, in degrees
cannot draw modded items!

Draw Flush

Flush the queued draw instruction(s) from the draw buffer to the specified displays with its building reference

Print

  • \n
    Writing \n will write the next text to a new line, example:

alt

  • Printing colors “ [ ] "
    You can change printed colors with [ ], example

alt

You can either put color names or hexadecimal color code
Example of HEX color code is #FF0000 for red, you can simply search “hex color picker” on google to choose your own color

  • Emoji/icons
    You can change printed colors with [ ], exampleNot really Mlog related but worth mentioning,
    Mindustry utilizes a specific range within the private use area of Unicode, these can be found on the source code : https://github.com/Anuken/Mindustry/blob/9eb8492f4ab8daf15685128229489b7229cc1048/core/assets/icons/icons.properties#L4
    which are:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    these might just look like boxes to you, but they are actually valid characters when pasted into the game
    other than this, Mindustry also supports some public unicode characters, though what of and in what range is unknown , attempting to paste unsuported characters will just show nothing.
    Here what they look like in game:

Print Flush

Flush the queued print instruction(s) from the text buffer to the specified message block with its building reference, will erases previous message on the message block

Get link

Get link gets the link of the processor linked building
example : you have 2 buildings linked to the processor, duo1 and duo2
getlink result #0 will get you duo1 and
getlink result #1 will get you duo2
The order is based on the order you link the buildings
The buildings reference is then result

altalt

Using it with numbers is pretty useless, they are usually used with incrementing variables as its index, this way you can get multiple buildings without writing every building reference (message1,2,3….)

Control

Controls a building of a building reference or a unit reference

  • Enabled
    Enabled or disable a building, can be 0 or 1 or true and false

of a block reference
to (state), 1 / true enable, 0 / false disable,
when disabling a processor it pauses code execution until re-enabled again, resuming at the line number where it was disabled
here is a list of blocks behaviour when disabled

  • Shoot
    Shoot at a unit/building but with velocity prediction

x and y is coordinate location where to aim/shoot at
shoot 0 or 1, true or false, if true tells the turret/unit to shoot, if false stop shooting

  • Shoot
    Shoot at a unit/building but with velocity prediction

unit, what object to aim/shoot at, it says "unit" but you can put a building reference there too.
shoot 0 or 1, true or false, if true tells the turret/unit to shoot, if false stop shooting

  • Config
    Change the configuration of buildings,
    for example :
    sorter config, by putting item name to the to arguments, eg @copper, @lead, @surge-alloy
    unit factory config, by putting unit name to the to arguments, eg @flare, @dagger, and of course it only supports units it meant to create, if you put other unit name that it cant create it will just deselect all unit

  • Color
    Change the color of Illuminator block Usually used with pack color

Radar

Radar a unit in range of the building’s range

alt

from is building reference
target is a filter, target enemy means it will only radar enemy units
order is sorting order, ascending or descending, can only be 0 or 1
sort is a metric to sort results by, sort distance means it will get unit by distance
In this example, since order is 1, and sort is distance, the unit returned is the closest to that building.
Cannot get multiple units at the same time.
Order cannot be change to look for metrics in the middle e.g 0.5
Will output the unit reference to result

Sensor

Sensor / get / read data from an object, usually buildings or units with their reference

alt

result is your named variable
@copper is what data to get from the specified object, can be a unit or a building. (click the pencil icon beside it for a list of sensorable data alternatively see Sensors for a list with explanation on each one)
block1 building reference, it is what object to get the data from, can also be a unit reference
Example:

alt

This will get the amount of copper in vault1, the number will be stored in the variable result, let’s say the vault has 10 coppers, therefore result will be 10

Set

Set a variable, either with numbers or with another variable (including unit or block reference)

Operation

Perform a single operation on 2 variables, or just numbers directly, example:

alt

Let’s say a is 10, therefore this operation means 10 + 5
result will then be 15

  • +
    Addition

  • -
    Subtraction

  • *
    Multiplication

  • /
    Division

  • //
    Integer division, like division but it will round down the results

  • ^
    Power / exponentiation

  • Sqrt
    Square root

  • ==
    Check if the 2 variables are equal to each other
    Returns 1 or 0 / true or false

  • Not
    Logical not, check if the 2 variables are not equal to each other
    Returns 1 or 0 / true or false

  • <
    Less than, check if the first variable is less than the second variable
    Returns 1 or 0 / true or false

  • >
    Less than equal, check if the first variable is less than equal the second variable
    Returns 1 or 0 / true or false

  • >=
    Greater than, check if the first variable is greater than the second variable
    Returns 1 or 0 / true or false

  • >=
    Greater than, check if the first variable is greater than the second variable
    Returns 1 or 0 / true or false

  • log
    Logarithm, return the exponent given the base and the result

  • log 10
    Logarithm in base 10

  • floor
    Floor , Round down the specified number

  • ceil
    Ceiling , Round up the specified number

  • max
    return the largest number out of the 2 number

  • min
    return the smallest number out of the 2 number

  • angle
    Angle of vector in degrees,usually used like: Angle = ((x1-x2) (y1-y2))
    internally the code does:
    ang1 = atan2(a,b) * 180/π (convert into degrees)
    result = { if ang1 < 0 = (ang1 + 360), otherwise = (ang1) }
    where a is the first variable and b is the second

  • angle diff
    Absolute distance between to angles in degrees, usually used like: angdiff = (ang1)(ang2)
    innternally the code does:
    a = a % 360
    b = b % 360
    d1 = (a - b + 360) % 360
    d2 = (b - a + 360) % 360
    result = min(d1, d2)
    where a is the first variable and b is the second

  • len
    Length of vector, usually used like: len = ((x1-x2) (y1-y2)).
    internally the code does:
    result = √ (a a + b b)
    where a is the first variable and b is the secondnoise

  • rand
    generate a random float in range of 0 to the specified value

  • sin
    Sin, in degrees

  • cos
    Cos, in degrees

  • tan
    Tan, in degrees

  • asin
    Asin, in degrees

  • atan
    Atan, in degrees

  • atan
    Atan, in degrees

Lookup

Look up an item/liquid/unit/block type by ID.
Total counts of each type can be accessed with:
@unitcount / @itemCount / @liquidCount / @blockCount, which is :
56 / 22 / 11 / 254 (as of v146), respectively, they are a constant.
For the inverse operation, sensor @id of the object
Example:

alt

This operation is looking up item with an id of 1, which is lead, thereforeresultwill then be@lead, acontent name, which can be used for things like sensor :

alt

lead_countis now a variable containing number of lead invault1
Lookup are usually used with anincrementing variable
Lists of IDs can be found in theAppendix

Pack Color

Packs RGBA color into a single number, is usually used with draw col and control color
Since it's a single number it can be stored to 1 address on cells/banks, instead of 4 addresses with the usual RGBA, making reading and writing a lot easier too.

alt

RGBA is their respective color, can also be directly written with a number, value is from 0 (dimmest) to 1 (brightest) You can unpack a Packed color by dividing it by %00000001, this will return 32-bit unsigned integer, 8 bits for each value, example : a 255,255,255,255 color when unpacked will return 4294967295, which is the maximum value of 32-bit unsigned integer, converting it to binary will return 11111111111111111111111111111111 ( 8 bit for each value ), by using the bit shift right operation and bitwise and operation you can extract each color value.

Wait

Wait the specified number of seconds, in other words, pausing the processor for that amount of seconds

Stop

Completely stops the processor from running, cannot be resumed in any way other than rebuilding or refreshing the code, to pause a processor disable it instead using control enable

End

End the process, when a processor run this line it will go back to 0 as if it reach the end of the instruction, similar to jump always 0

Jump

Jump to a line number on the processor with a condition
if condition are true jump to the specified line, if false does not jump (continuing to instruction below it

  • ==
    Check if the 2 variables are equal to each other

  • Not
    Logical not, check if the 2 variables are not equal to each other

  • <
    Less than, check if the first variable is less than the second variable

  • <=
    Less than equal, check if the first variable is less than equal the second variable

  • >
    Less than equal, check if the first variable is less than equal the second variable

  • >=
    Greater than equal, check if the first variable is greater than equal the second variable

  • ===
    Strict equal, usually used to check for null, example:
    0 null is true, while 0 = null is false

  • Always
    Always jump regardless