Simple Logic examples
From now on i will start documenting logic invention, Mlog Invention
if you have a logic schematic/program/invention you want to be documented here feel free to dm me
Universal Switch

line 0 : sensor for @enabled in switch1, stores the state in the switch variable
line 1 : getlink with link, which is an incrementing variable
line 2 : sensor for @type in block for later
line 3 : increment the variable link
line 4 : resets the variable link when it reached @links using the % operator
line 5 : jump if type is @switch, this ensures that the switch building does not get controlled
line 6 : control the enabled of block, which is the results of getlink, to switch
Shuttle Logic
Line 0 : bind a flare
Line 1 : locate an ally core, outputs its coordinates to cx,cy, and building reference to core
Line 2 - 3 : get the coordinates of the linked vault using sensor
Line 4 : sensoring the @totalItems from @unit to get the amount of items the unit are currently carrying
Line 5 : a conditional jump, jump to (move to core) and take item if the item the unit are currently carrying is 0
Else jump to move to (vault and drop item)
Line 6-7: move to vault and take item from vault
Line 8 : end, to make sure both (move to core) and (move to vault) cannot run in the same time
Line 9-10 : move to core and take @copper from core
The key is to not put 2 or more move that the processor can run “simultaneously”, in other words don’t make the unit move to 2 location or more “simultaneously” Either move to core or move to vault based on a condition
Thorium Reactor Fail Safe

line 0 : getlink with i, which is an incrementing variable, writes the result to block
line 1 : sensor for cryofluid in block, writes the result to cryo
line 2 : compare if cryo > (greater than) 15, if it is fail will be true, else fail will be false
line 3 : control block to fail which controls the thorium reactors to fail, if line 2 is true then fail is true, thus enabling the thorium reactor
line 4 : incrementing the variable i
line 5 : resets the variable i when it reached @links using the % operator
@counter Array
This is a bit more advanced than previous examples but it is very useful especially for unit multibind, assuming you already know what an array is you can simulate it using the @counter variable
The variable ‘array’ is now an array, this is a static array, meaning the size of the array is fixed, you can however expand the size of the array to how many you want