Extras
Extras
These are niche question that very small number of people might have
Mindustry coordinate system
unlike traditional Cartesian Coordinate System where the center point of a coordinate is on the edge of a block Mindustry chooses the middle of a block as its center point instead
the game still uses Cartesian but just offset by 0.5
the game also by default set 0,0 to the very bottom left of the world, this means all campaign world and most custom worlds (since you can set the coordinate offset in the editor) playfield are always positive
The word configure turns to config
in v6 the config property was renamed to configure. To ensure backwards compatibility with old code the game automatically changes the word configure to config
if you use this as a variable it will still works, you just can't have "configure" anymore
this applies both when writing in game and importing from text
You cannot spawn Scathe missile
To spawn a Scathe missile you have to spawn a unit capable of carrying a payload, set that unit payload to scathe missile using setprop and @scathe-missle, make the unit drop the payload and then kill the unit
you can also setprop properties of the scathe missile.
by using fetch with @scathe-missile as the unit argument you can get the scathe missile reference
you can put this reference to the setprop instruction to set the properties of the missile.
Modded items and draw image
the game doesn’t generate logic icons for modded items, this means you cannot draw it using draw image
AI chatbot doesn’t understand Mlog
AI chatbot like ChatGPT / Copilot / Aria, can’t do and doesn’t understand Mlog, to my knowledge there is no AI currently that can assist you with Mlog
Getting unit cap
There currently no way of getting the unit cap consistently, there are workarounds however, assuming the default cap isn’t changed you can count how many cores there are in the map and what type it is, if you know both of those you can get the unit cap by summing up all of those core(s) ‘Max Active Unit’ Shard has a unit cap of 8, foundation is 16, and nucleus is 24, info of which can be found in the game’s info menu
v6 unit controls with logic
you cannot 100% replicate v6 unit controlling with logic, formation and shooting is possible, but support units cannot help you build like they used to in v6, although not perfect the RTS controls is the best we currently have
Damage calculation
every unit has an armor value, in most cases damage is just simply subtracted by this armor value, formula is
damage received = max (damage 0.1 , damage - armor)
example :
unit = corvus, armor = 9
enemy turret = lancer, damage = 140
damage received = max ( 140 0.1 , 140 - 9)
damage received = max ( 14 , 131)
damage received = 131
Math
Math is useful in every language. Since there are so many topics, I will only explain the ones commonly used in Mindustry.
Trigonometry
Sine
Calculates how much a point moves along the Y-axis based on an angle.
for example: Imagine a clock hand (arrow) with a length of 1, the arrow is currently point to 3 o'clock, let's say that is 0°,
now rotate the arrow counterclock wise by 45°, the arrow is now pointing between 1 and 2 (1:30),
now place a point at the tip of the arrow,
in just the Y-axis what is the length from the center of the clock to that point?
this is what sin(45°) gets, which is 0.707106...,
Cosine does the same but in the X-axis instead
using this you can plot a point based on another point
for example you want to plot a point in front of a unit, sensor its @rotation, sine and cosine it,
the new point formula is Xnew = Xcurrent + Cos(@rotation) and Ynew = Ycurrent + Sin(@rotation)
where Xcurrent and Ycurrent is the current location of the unit, which you can get by sensoring it for @x and @y
this will plot a point with a length exactly 1 from the unit, to increase the length just multiply the output of the sine and cosine:
5*Cos(@rotation) and 5*Sin(@rotation), same as before add this to the current unit position, this will make a point in front of the unit with a length of exactly 5LERP (Linear Interpolation)
in Mindustry it is mainly used for getting a point in between 2 known points, the general formula are:
Xnew = (1 - t) X1 + t X2
Ynew = (1 - t) Y1 + t Y2
where X1 and Y1 is the first known point and
X2 and Y2 is the second known point
t is ratio from 1 point to the other, for example if you wanna get a point in the middle of 2 known point put t as 0.5
or if you want 75% of the way, put t as 0.75Vectors
Vector is defined by a : Direction, and Magnitude
Direction is where the vector is pointing at
Magnitude is how long the vector is
for example : a vector with direction of (1,0), since the X component of the direction is 1 and Y is 0 this means the vector is pointing straight to the right with a magnitude of 1
how do we know this?
assume the vector base is (0,0) then draw a point with the direction as its location (1,0), now you have 2 points, from the vector base draw a line/arrow to the second point, now you know where the vector is pointing
to get the magnitude we have to do some calculation:
Magnitude = √(Dx)2 + (Dy)2
or you can use mindustry built in instruction the op len by putting Dx and Dy
for 2 points in space how do we get a vector from one to another?
if you remember vector is just a point pointing to another point in space
point A : (10,10) point B : (15,20), let's say you want to get a vector from A to B
you only need to get the displacement from A to B, this can be easily calculated by just subtracting each component from each point
C = (Bx - Ax), (By - Ay)
C = (5,10), thats it, C is now a vector
if you add C to A the location of A will now become B, add it again it will be at another point of (20,30)
what is the use of vector?, imagine you have a ball, you throw it directly upwards with the speed of let's say 10 unit/second, that ball now have a vector of (0,10), vector can be used to determined an object velocity
in programming, you have a point that you want to move, unlike reality you cannot move an object with infinite precision , you can only step through (usually per tick), you want to move it 12 units to the right per second, its simple, just add (12,0) to your point every second, you might say it looks like its jumping not moving, well we really can't get an object to move in the digital world like in reality only the illusion of moving, so you want to add the vector to your point in quicker succession with smaller magnitude, let's say 60 times per seconds you want to add (0.2,0) to your point every 1/60th of a second to get it to move 12 units in 1 second
Linking a processor to itself
normally control enabled @this 0, doesn't work, but if you link the processor to itself it does
to link a processor to itself you either need a modified schematic file or using the console:Vars.world.tile(x, y).build.links.add(new LogicBlock.LogicLink(x, y, "processor1", true))
replace the x and y to the coordinates of the processor, and paste it to the console, this will make the processor link it self
now control enabled @this 0 will work,
there might be some other uses for it, but i haven't found any, if you do feel free to contact me so i can update this