Stormworks: Build and Rescue

Stormworks: Build and Rescue

149 ratings
Logic Reference Guide
By Zulban
Descriptions of all logic available in the game so far. While not necessarily a tutorial, this guide aims to help those who are new to using logic, or haven't used similar systems in other games before.
17
2
   
Award
Favorite
Favorited
Unfavorite
Logic Basics and terminology
Before getting to the logic gates there are a few rules that apply to pretty much all logic and some useful terminology that is good to know. There are two kinds of logic commonly used in Stormworks: On/Off and Number, represented with red and green colors respectively. Players with color blindness can change the color of the nodes under Options►General►Accessibility►Color Palette, but this guide is going to be referencing the default colors where applicable.

All logic uses nodes which come in two varieties: INput and OUTput. Inputs are represented by colored circles, and outputs are represented by dots. Inputs can only accept a single output. On the contrary, a single output can send signals to an unlimited number of inputs. A colored line is drawn from the output node to any input nodes it is connected to along with an animated arrow pointing to the outputs. When hovering the mouse over any logic node any node that it is connected to will be highlighted in white. When connecting nodes together you can drag from the output or from the input, either will make a connection, and holding CTRL while clicking will allow making multiple connections.

Left: multiple Boolean outputs connected to a single input using an OR gate.
Right: a single Number output connected to multiple inputs, including a Threshold gate that activates an indicator light when the number is in a certain range.


In addition to logic nodes, some logic may have properties which can be changed by clicking on them and using the panel on the left of the screen (physical logic gates need to be selected using the Select tool). When working with microcontrollers it's possible to modify them in the properties panel by clicking the blue and white button to the right of its name, allowing you to make changes without having to delete them and putting them down again.

Logic types
The most basic kind of logic is Boolean (Bool·e·an), which is referred to as On/Off in Stormworks. As the name suggests, Boolean has one of two states: on or off, and can be considered 'digital'. When a component receives a signal it usually activates, changes state, or does something else special depending on the component. The states of this kind of logic can also be referred to as: true or false, "sends/receives a signal" or "no signal", high or low, and possibly more that describes whether a signal is active or not. When nothing is connected to a Boolean input it will default to false, or 'off'.

The other kind of logic is Numbers. Numbers can be any positive or negative number (besides things like √-1 but you wouldn't be silly enough to try to break the game right? You can't have operators like + * % ÷ in a number anyways). While booleans can only be true or false, numbers are either constants or variables, typically the latter, and can be considered 'analog'. While booleans are typically used like a light switch, numbers can do a myriad of things, such as measure the speed of a vehicle or set the throttle of an engine. Number logic can be used to turn number inputs into a boolean output (I.E. if X is greater than Y: output TRUE). When nothing is connected to a Number input then it will default to 0.

There are other kinds of logic in Stormworks, however they are typically special cases. Composite logic is a special logic type represented by violet nodes. Composite logic combines up to 32 boolean and 32 number signals into a single connection, commonly used to work with instrument panels but can also be used to create remote controlled vehicles. Audio and Video logic is represented by olive and teal respectively. As expected these are used for sending audio from microphones to a megaphone or radio, and for sending video feed from a camera or LUA Script to a display monitor.

Physical logic gates and microcontrollers
Logic gates are listed under the 'logic' portion of the inventory, assuming you're sorting the inventory by category and not alphabetically. While using these physical logic gates works fine, it may be preferable to use microcontrollers instead which can dramatically decrease how many logic gates are on your creations. Do note however that some logic gates are unavailable to microcontrollers, and there is plenty of logic that is exclusive to microcontrollers. Any logic that is available in a microcontroller works identically to their physical counterparts unless otherwise noted.

Ticks and logic speed
Most of the time logic will execute its functions seemingly instantly, however it's still important to note that it is not instant. Logic time is measured in 'ticks', with each tick being 1/60th of a second (60 ticks per second). Every piece of logic takes one tick to process, which can sometimes affect other logic or the behavior of a vehicle if you have a very long chain of logic (a MASSIVE chain of 60 logic gates would take a whole second to process for example). Most of the times this is negligible but it's something to keep in mind. Because logic time is measured in ticks, some logic will change its values on a per tick basis. For example, a Counter set to increase by 1 will have an output of 60 after just one second. When working with these speeds you may need to enter very small numbers to get the desired effect.
Example 'vehicle'
If you wish to see simple examples for each logic then I made a vehicle. Start a creative mode game and load the vehicle in the large hangar. The logic appears in the order listed in this guide, starting from left to right. The microcontroller logic board is behind the boolean and number boards.
https://steamcommunity.com/sharedfiles/filedetails/?id=2095564440
Boolean logic (On/Off)
Now on to the logic. I'm going to order these roughly from least complicated to most complicated.
Constant On Signal

Inputs
Outputs
 
Boolean: On

A simple logic component that continuously outputs an on signal. This is useful for creating logic circuits that are permanently switched on.
The most basic logic, should be self explanatory.

NOT

Inputs
Outputs
Boolean: A
Boolean: NOT A

A logic gate that outputs the logical NOT of its input signal. The output will always be the opposite of the input.
This inverts an incoming signal, so if you send a signal then its output will turn off. Turning off the input will turn on its output.

Push to Toggle

Inputs
Outputs
Boolean: Toggle Signal
Boolean: Internal State

This component has an internal on/off switch that is toggled every time a new on signal is sent to its output. This can allow regular push buttons to act as toggle buttons
When this receives a signal it will toggle its output state, regardless of how long or short the input signal is held for. It will not change its output again until its input goes from off to on. This is a rudimentary variant of the SR Latch explained later.

AND
Inputs
Outputs
Boolean: A
Boolean: A AND B
Boolean: B
A logic gate that outputs the logical AND of two input signals. The output will only be switched on if both inputs are on.
Another self-explanatory logic gate, but one of the most common ones. If you only want something to activate when two other things are also both active then you will need this.

OR
Inputs
Outputs
Boolean: A
Boolean: A OR B
Boolean: B
A logic gate that outputs the logical OR of two input signals. The output will be switched on if either of the inputs is on, and off if neither are on.
Like an AND gate, but only one of the two inputs needs to be active to output a signal, but both inputs activating also activates the output. Fun experiment: hook the output of an 'OR' into one of its inputs to create a 'latch'.

XOR
Inputs
Outputs
Boolean: A
Boolean: A XOR B
Boolean: B
A logic gate that outputs the logical XOR of two input signals. The output will be switched on if only one of the signals are on. The output will be switched off if the two signals are the same
This is like the OR gate, except only one of the inputs is allowed to be on at a time for it to activate.

Blinker

Inputs
Outputs
Boolean: Control Signal
Boolean: Blinking Signal

The Blinker outputs a value that blinks between on and off at a set rate. You can set the duration that the signal should stay on and off for by selecting it with the select tool. A control signal determines whether or not the blinker should output anything. If the control signal is off, the blinker's output will be off. The internal blink timer is reset every time the control signal is switched off.
Once again the game says everything that needs to be said. Use this If you want something to receive a signal only at set intervals, such as a blinking anti-collision light or a siren.

Delay
Inputs
Outputs
Boolean: Signal to Delay
Boolean: Delayed Signal
This component stores an input on/off signal, and then outputs it after a delay. The delay time can be configured by selecting the component with the select tool. The internal delay timer is reset whenever the input signal changes.
Not available for microcontrollers. Does what it says on the tin. It needs to receive a signal (or not receive one) all the way up until its time is up before the output state changes.

Capacitor

Inputs
Outputs
Boolean: Charge
Boolean: Stored Charge

Charges up when receiving an on signal, then discharges over a period of time. The charge and discharge times can be configured with the select tool. Once charged, inputting a new signal will reset the discharge timer.
This is basically a Delay, except you can individually change how long it takes before it activates when receiving a signal and how long it takes before it deactivates when it stops getting a signal. Setting the timers to 0 will immediately activate (or deactivate) the moment it gets any signal at all (or stops getting one).

SR Latch
Inputs
Outputs
Boolean: Set
Boolean: Output
Boolean: Reset
Boolean: NOT Output
An SR Latch that can be set and reset using two on/off inputs. When both inputs are off, there is no change in state. If both Set and Reset are set to on, and invalid state will be created and both Outputs will be set to Off.
This is similar to the Push to Toggle, except it has two inputs. One input will toggle it on, but activating that same input again will not toggle the latch off. In order to reset the latch you specifically need to use the other input to deactivate or 'reset' the latch. For convenience there is a 'not' output built into this SR latch to signal when its sate is 'off', which is the same as having a 'not' gate after its normal output. By default this will spawn in the 'off' state so don't worry about having to set it to the correct state when spawning your vehicles. It behaves strangely if both inputs are active at the same time, so try to avoid that.

JK Flip-Flop
Inputs
Outputs
Boolean: Set
Boolean: Output
Boolean: Reset
Boolean: NOT Output
A JK Flip-flop that can be set and reset using two on/off inputs. When both inputs are off, there is no change in state. If both Set and Reset are set to on on, the state will be toggled.
This is a more fancy SR Latch. It's basically made for if you expect a situation where both inputs might be active at the same time and tries to prevent oddities or unpredictable outputs.
Number Logic Pt. 1
Constant Number

Inputs
Outputs
 
Number: Constant number

Outputs a constant numerical value. The number that is being outputted can be configured by selecting this component with the select tool
Just like the Constant On logic, this will always output the number you assign to it in the vehicle editor. Also, you read that correctly... 'outputted'. Surprisingly it's a valid past tense of 'output', but I still hate it.

Numerical Inverter
Inputs
Outputs
Number: Number to Invert
Number: Inverted Number
The inverter takes a number as input, multiplies it by -1, and outputs the result.
Not available for microcontrollers. This is useful if you discover the controls from your driver's seat are backwards, just pass it through one of these and presto! If you want this in a micrcontroller use a function set to -x

ABS

Inputs
Outputs
Number: Inpute Number
Number: Absolute Value

Outputs the absolute value of a number input. Negative numbers are converted to positive numbers, whilst positive numbers are unchanged.
Absolute Value is useful if you need to know 'how far is a number from 0' and guaranteeing that it's a positive number (or negative using an inverter) is important. As an example speed can sometimes be measured in negative numbers but you might only care about the absolute speed.

Add
Inputs
Outputs
Number: A
Number: A + B
Number: B
Takes two number inputs, adds them together, and outputs the result.
Hopefully you know what addition is.

Subtract
Inputs
Outputs
Number: A
Number: A - B
Number: B
Takes two number inputs, subtracts the second from the first, and outputs the result
Same as the ADD logic, but treats the second input (input B) as a negative number (or positive I guess, if it was already negative). Hopefully this is self explanatory.

Multiply
Inputs
Outputs
Number: A
Number: A x B
Number: B
Takes two number inputs, multiplies them together, and outputs the result.
Like the ADD gate, but multiple times better. Otherwise nothing special to note.

Divide
Inputs
Outputs
Number: A
Number: A / B
Number: B
Boolean: Divide By Zero
Takes two number inputs, divides one by the other, and outputs the result. If a division by 0 occurs, an on signal will be produced and the output number value will be set to 0.
The description doesn't mention this as it's assumed, but this is important: input A is the dividend and input B is the divisor. In other words A is divided by B. Get it backwards and you'll be sad (until you fix it). Also note that boolean output; trying to divide by zero will turn that output on. Unlike a your typical calculator, division by zero outputs a 0 since numbers cannot be 'not a number' in Stormworks.

Greater-Than
Inputs
Outputs
Number: A
Number: A > B
Number: B
Compares two numerical values. Outputs an on signal if the first input is greater than the second, and outputs an off signal if the first input is less than or equal to the second.
Not much to add to the in-game description.

Less-Than
Inputs
Outputs
Number: A
Number: A < B
Number: B
Compares two numerical values. Outputs an on signal if the first input is less than the second, and outputs an off signal if the first input is greater than or equal to the second.
This is the opposite of the Greater-Than logic, if you need it.

Threshold Gate

Inputs
Outputs
Number: Value to Test
Boolean: Within Threshold

Takes a value and compares it to a set threshold. A lower and upper bound to the threshold must be set. The output is set to on if the input value is less than or equal to the upper bound, and greater than or equal to the lower bound. If it is outside this range, the output is set to off. The threshold bounds can be configured by selecting this component with the select tool.
This is a sort of combination of Greater-Than and Less-Than gates. Unlike those logic gates, the upper and lower bounds of a Threshold Gate are set constants and cannot be changed outside of the vehicle editor.

Clamp

Inputs
Outputs
Number: Number to Clamp
Boolean: Clamped Number

The clamp takes a number input and clamps it to a set range. The upper and lower values to clamp to can be configured by selecting this component with the select tool.
Any number this logic outputs will always be within the range set in its properties, no matter what its input is.

Counter
Inputs
Outputs
Number: Speed
Number: Count
A counter which increases with a set speed. Stores and constantly outputs a value which increases by an input amount.
Not available for microcontrollers. As long as the input is not 0 the counter will go up (or down with negative numbers). Remember that logic uses ticks for speed, with 60 ticks per second, so the output number will change by the input value every 1/60th of a second.

Counter (Ping Pong)
Inputs
Outputs
Number: Speed
Number: Count
A counter which oscillates between -1 and +1 with a set speed.
Not available for microcontrollers. Very similar to the normal counter, except any time the counter reaches 1 it will reverse, and then reverse again when it reaches -1. Again the speed is measured in ticks, so adjust the input accordingly.
Number Logic Pt. 2
UP/DOWN
Inputs
Outputs
Boolean: Up
Number: Up/Down Value
Boolean: Down
This component uses two on/off signals to move an internal value between -1 and 1. The up input moves the value towards 1 and the down input moves it towards -1. This component can be used for converting on/off button presses into a standard number value that can be used to control any mechanical components that accept a standard number input.
The microcontroller version of this has its own section in the microcontroller section since it's different enough. The 'Throttle Lever' component is essentially a fancy looking UP/DOWN logic with buttons built in, so if you've used a Throttle Lever then you know what this is. The in-game description is slightly misleading but nothing too major. You can use the select tool to change the 'clamped' value to something other than -1 and 1. This logic is useful for if you need to somehow convert digital signals into an analog output, for example steering using button pushes instead of a control chair.

Numerical Switchbox
Inputs
Outputs
Number: First Value (On)
Number: Switched Value
Number: Second Value (Off)
Boolean: Switch Signal
Acts as a switchbox for two number signals. Which of the two inputs is sent to the output is determined by the on/off switch signal. When the signal is on, the first value is sent to the output. When it is off, the second output is sent.
Remember that input nodes can only accept a single output. This logic allows you to have two outputs going to an input, and you can switch which input is sent using a signal. Just remember that signals are off by default so the second number will be what's sent by default until this gets an on signal. There's a good chance you'll get a lot of use out of switchboxes because of how useful they are.

Numerical Junction
Inputs
Outputs
Number: Value to Pass Through
Number: On Path
Boolean: Switch Signal
Number: Off Path
Acts as a junction for two number signals The junction can be switched using an on/off signal. When the signal is on, the number is passed through to the first output and a value of 0 is passed to the second. When the signal is off, the number is passed through to the second output with the first being set to 0.
This is the opposite of a switchbox. You have one input number but you want to decide which of two outputs you need to send it to while accepting that whatever path isn't chosen gets a 0.

Function (1 Input)

Inputs
Outputs
Number: Input 1 (x)
Number: f(x)

Evaluates a mathematical function with 1 variable inputs The function can be entered by selecting this component with the select tool. A full list of valid operations are also visible in the component's selection menu.
Allows you to do a whole ton of math using just a single logic piece, which can be very useful if you need to use particularly complex formulas that would normally take a lot more space to do. Also has functions not available to math blocks like square root, rounding, selecting the higher or lower of two values, etc. 'x' in the equation, without quotes, represents the single input value.

Function (3 Inputs)
Inputs
Outputs
Number: Input 1 (x)
Number: f(x,y,z)
Number: Input 2 (y)
Number: Input 3 (z)
Evaluates a mathematical function with up to 3 variable inputs. The function can be entered by selecting this component with the select tool. A full list of valid operations are also visible in the component's selection menu.
Like the 1 input function, the 3 input function works exactly the same except now you have more variable inputs. There are three inputs but you don't need to use all of them. Take note which input represents what variable in your function (x, y, or z). Now all of those other single-operator logic gates seem pretty lame when this can replace them all.

Memory Register
Inputs
Outputs
Number: Value to Store
Number: Stored Value
Boolean: Set
Boolean: Clear
A memory register that can store a number value. The number input will be stored when an on signal is received. A secondary on/off signal can be used to clear the stored value, resetting it to the configured value set using the select tool.
This acts as memory, so if you need to store a value (I.E. how much fuel you have currently) and recall it later (I.E. compare current fuel to the value stored earlier to see fuel usage) then you would use this.

MODULO
Inputs
Outputs
Number: A
Number: A % B
Number: B
Takes two number inputs, outputs the remainder after dividing the first by the second.
The % symbol is the operator symbol for Modulo, in case you use it in functions logic. This is sort of a strange one, it's similar to the Division logic. Instead of outputting like normal, it will divide until further division isn't possible, then outputs the remainder. For example 53 divided by 5 would normally output 10.6, but modulo will instead divide until it can't any more, then find the remainder and output that. 53/5 = 10 with 3 left over, so the output would be 3. Sorry if this is a bit hard to explain.

Trigonometry
Inputs
Outputs
Number: Input Number
Number: f(x)
Provides a set of basic trigonometry functions. The available functions are sin. cos, tan, asin, acos, and atan. If an invalid number is input, the output will be 0. Sin, cos, and tan accept inputs measured in turns. Asin, acos, and atan output values measured in turns. The function can be set by selecting this component with the select tool.
Not available for microcontrollers, but it's not necessary. Sure, if you need it it's there, but all of the functions in the Trigonometry block are also available in the Function blocks. So, a bit redundant.
PID
Yes, this is getting its very own section.
PID Controller
Inputs
Outputs
Number: Setpoint
Number: Control Output
Number: Process Variable
Boolean: Active
A control loop feedback mechanism that measures and corrects the error in a system over time. It takes the current measured output of a system or sensor, and a desired target measurement. It outputs a value that can be used as an input to the system to gradually correct its error. For example, the controller could input to an engine's throttle to maintain a desired speed or altitude. The control terms (proportional, integral and derivative) can be set by selecting the component with the select tool. The control terms must be carefully tuned for optimal output.
I can see you running for the hills, but the PID is not going to hurt you (If it was, it knows where you're hiding anyways). The PID is your friend... usually. It may be hard to understand and frustrating to work with but it is a powerful tool when used correctly. This logic deserves (and has) its own guides dedicated to it but I will attempt to break it down here.

Something in your creation is deviating from where you want it to be (this can be anything from the roll of a boat, the RPS of an engine, the altitude of a plane, or just about anything else). This is called the 'process variable', and where you want this process variable to be is called the 'setpoint' or target. The difference between the process variable and the setpoint is the 'error'. The entire job of the PID is to reduce this error to 0 and keep it there. It achieves this in three ways, or less if the values are set to 0.

Three main values: P, I, and D
Proportional Gain: I consider this the Power of the PID. As the name suggests, the proportional gain will output a value in proportion to the process variable. If P is set to 1, then it will output the opposite of what the process variable is, so if the process variable is 1, then proportional gain will output a -1 in an attempt to bring the process variable to the setpoint, assuming the setpoint is also 0. If instead the setpoint were 1 then proportional gain would output 0 since the process variable is already at the setpoint. If you are using a sensor to get the process variable then note that some sensors output very small (or large) numbers, so adjust the PID accordingly. For example a tilt sensor does not go above 0.25 or below -0.25 so proportional gain would never go above 0.25 or -0.25 when the setpoint is 0, even though many objects such as rudder fins accept an input between 1 and -1.

Integral Gain: I consider this the Impatience of the PID. This is very hard to work with and a lot of times you are better off leaving this at 0. What this does is gradually change the PID output the longer the process variable has spent 'away' from the setpoint. So, if the process variable is just hovering around -0.5 and refuses to go up to 0 no matter how much time has passed, then Integral Gain will keep increasing its output until the setpoint is finally reached. Remember that logic time is measured in ticks so this will need to be a very, very low number if you decide to use it at all since it will be increasing 60 times per second. Also remember that as long as the PID is active this will be changing, so if you want to reset it just turn it off and on again.

Derivative Gain: I consider this the Dampening of the PID. While Proportional Gain only looks at how far the process variable is from the setpoint, and Integral Gain only looks at the time the process variable has spent away from the setpoint, the Derivative gain is focused on how quickly the process variable is approaching or moving away from the setpoint. If the process variable is speeding towards the setpoint it is highly likely that it will overshoot it and you will end up with 'oscillations' where things just get wobbly and never even out. Derivative Gain will spot the process variably quickly approaching the setpoint and try to add a 'braking force' to the PID output to try to keep it from overshooting too much. It's possible you can get away with this being relatively high, but you will need to find what works for your situation.

What about the output?
So you have your PID measuring something in your vehicle that is misbehaving, but now you need to know where you need to output the PID. If the process variable comes from a sensor of some sort to detect an error, then you'll want to output the PID to something that can actually fix the problem. If an engine RPS is wrong then the output goes to the throttle, or even a clutch. If an airplane is constantly yawing or rolling then the output goes to the control fins.

So, with all that said... hopefully it gets you started. I suggest looking at a dedicated guide if you want to learn more about these beasts. Remember, all of this is from my personal understanding, so it might not be completely accurate, but it should hopefully be good enough.

PID Controller (Advanced)
Inputs
Outputs
Number: Setpoint
Number: Control Output
Number: Process Variable
Number: Proportional Gain
Number: Integral Gain
Number: Derivative Gain
Boolean: Active
A PID controller with variable proportional, integral and derivative gains.
Microcontrollers possess a special PID controller that is worth mentioning. With a normal PID the three control values are set in the vehicle editor and can't be modified after spawning the vehicle. The advanced PID however has inputs for all of these controls. If you want to try to tune a PID in real time without having to constantly bring the vehicle in and out of the workbench, then try hooking up some keypads or throttle levers to the inputs of an advanced PID instead. You can also use logic to change the strength of the PID on the fly.
Microcontroller Logic Pt. 1
There is a lot of logic that can be exclusively found within the microcontroller editor. Any microcontroller logic that is identical to its physical counterparts are simply going to be skipped.

NAND
Inputs
Outputs
Boolean: A
Boolean: A NAND B
Boolean: B
Outputs the logical NAND of its two input signals.
A "Not And" gate. Essentially an AND gate followed by a NOT gate (notice the little dot in the symbol). This will constantly output an on signal until both of its inputs are true, at which point it turns off.

NOR
Inputs
Outputs
Boolean: A
Boolean: A NOR B
Boolean: B
Outputs the logical NOR of its two input signals.
A "Not OR" gate. An OR gate with a built-in NOT on its output. Outputs an on signal unless any combination of its two inputs turn on.

Boolean f(x,y,z.w) / Boolean f(x,y,z,w,a,b,c,d)
Inputs
Outputs
Boolean: ‡
Boolean: f(‡)
‡ there are multiple inputs for function blocks, depending on which function block is used.
Evaluates a logical expression with up to 4/8 input variables and outputs the result
This allows you to perform any number and combination of AND, OR, XOR, or NOT operations on boolean signals. Parentheses also works just like in normal function blocks. There are two varieties of this block that work the same, but the only difference is one has four inputs while the other has eight inputs to work with. If you have a long string of comparative boolean logic it's possible to condense them down into a single function.

f(x, y, z, w, a, b, c, d)

Inputs
Outputs
Number: ‡
Number: f(x, y, z, w, a, b, c, d)
‡ Eight inputs ranging from W-Z and A-D
Evaluates a mathematical expression with up to 8 input variables and outputs the result.
Works just like the other function logic, except now there are 8 inputs to work with.

PULSE (Toggle to push)

Inputs
Outputs
Boolean: Toggle Signal
Boolean: Pulse

A switch that outputs a single tick pulse. It can be configured to pulse when being switched from off to on (default), on to off, of always when the input signal changes.
The Pulse logic will only ever output a signal for the minimum amount of time required to activate anything it's output to, which is a single tick. The pulse will not output again until the input's state changes, which can be changed in its properties. Connecting a Constant On to this will output a pulse a single time when the vehicle spawns but won't pulse again afterwards.

DELTA

Inputs
Outputs
Number: Inpute Value
Number: Delta of Input Value

Outputs the difference between the input and the input from the previous tick.
A bit finnicky to work with, but this is the easiest way to measure the rate at something changes, such as how much fuel is used per tick (you'd probably want to use math to convert that into per minute, or per second).

EQUAL
Inputs
Outputs
Boolean: A
Boolean: A = B
Boolean: B
Compares whether or not two numbers are equal within a set accuracy.
This works a bit like a threshold gate. The 'epsilon' property is how close the two numbers need to match before the output turns on. Setting it higher means there can be a large deviation but setting it smaller means the two inputs need to match each other more closely.
Microcontroller Logic Pt. 2
Up/Down Counter
Inputs
Outputs
Boolean: Up
Number: Value
Boolean: Down
Boolean: Reset
Has an internal value that will increase and decrease when receiving different signals.
This is very similar to the physical version, but functions differently enough that I am covering it again. First, instead of a 'sensitivity' there is actually an increment property that acts just like a regular counter (increases per tick). Secondly the output does not need to be clamped if you don't want it to be. Finally there is a third input that will set the output back to the reset (default) value when it gets a signal.

Timer (TOF)
Inputs
Outputs
Boolean: Timer Enable
Boolean: Timing Complete
Number: Duration
Variable input timer. Outputs an on signal when the timer is less than its duration. The timer will reset when off.
TOF stands for "Timer OFf". When enabled, the timer will output a signal. Once the duration is up or the timer is disabled the output will turn off. The timer will reset once turned off. Duration can be set to be in seconds or ticks.

Timer (TON)
Inputs
Outputs
Boolean: Timer Enable
Boolean: Timing
Number: Duration
Variable input timer. Outputs an on signal when the timer reaches its duration. The timer will reset when off.
TON stands for "Timer ON". When timing is enabled the timer will wait until its duration is over and then constantly output an on signal. Turning the timer off at any point will reset the timer and disable the output if it's enabled. Duration can be set to be in seconds or ticks.

Timer (RTF)
Inputs
Outputs
Boolean: Timer Enable
Boolean: Timing Complete
Number: Duration
Boolean: Reset
Variable input timer. Outputs an on signal when the timer is less than its duration. The timer will not reset until it is signalled.
RTF stands for "Retentive Timer oFf". As long as the 'timer enabled' input is on then the timer will output a signal until it reaches the end of the duration set by its duration input. Any time the reset activates it will go back to the beginning of the timer. If at any point 'timer enabled' turns off then the timer and its output get disabled immediately. Duration can be set to be in seconds or ticks.

Timer (RTO)
Inputs
Outputs
Boolean: Timer Enable
Boolean: Timing
Number: Duration
Boolean: Reset
Variable input timer. Outputs an on signal when the timer reaches its duration. The timer will not reset until it is signalled.
RTO stands for "Retentive Timer On". Opposite of the RTF, its output will not activate until Timer Enabled is activated and reaches its duration. Resetting it will turn the output off until the timer duration is reached again. As with the RTF, disabling the Timer Enable input will shut the entire thing off. Duration can be set to be in seconds or ticks.

Audio Switchbox
Inputs
Outputs
Audio: Audio 1 (On)
Audio: Audio Output
Audio: Audio 2 (Off)
Boolean: Switch Signal
Outputs the first input audio when receiving an on signal, and the second when receiving an off signal.
This works identically to a normal switchbox, except instead of routing digital signals it works using audio logic. It selects which of its two audio inputs to output depending on the state of the Switch Signal input.

Video Switchbox
Inputs
Outputs
Video: Video 1 (On)
Video: Video Output
Video: Video 2 (Off)
Boolean: Switch Signal
Outputs the first input video when receiving an on signal, and the second when receiving an off signal.
This works identically to a normal switchbox, except instead of routing digital signals it works using video logic. It selects which of its two video inputs to output depending on the state of the Switch Signal input.

LUA Script
Inputs
Outputs
Composite: Data Input
Composite: Data Output
Video: Video Input
Video: Video Output
Runs a custom lua script for advanced logic and drawing to monitors.
If you know how to use LUA Script then you can probably replace all of these logic gates with a script. Remember that all logic is processed in a single tick, so an entire LUA Script will be executed in a single tick, which is one of the reasons it has a 4096 character limit. LUA Script can use its composite signal to talk to other LUA Script in a chain to make more complicated logic or even draw images to monitors that wouldn't fit into a single LUA Script.

For thinking impaired plebians such as myself however, LUA Script is good for writing text to a video screen and maybe drawing a static line if I'm feeling especially confident.
Properties and Tooltips
Properties are special logic that can be set by clicking the microcontroller with the select tool without needing to open them up in the MC editor. These act as either Constant On or Constant Numbers that will change depending on what properties you set them to. All properties have a Property Name field which the user will see next to the property they are modifying in the vehicle editor, but can also be referenced by LUA Script (case sensitive).



Tooltips will display information to a player that looks directly at the microcontroller, just like when looking directly at an engine or dial etc.

Properties and Tooltips will be displayed in the order they are placed in the editor, so to arrange which gets listed first you may need to do some cutting and pasting.

Property Toggle
Properties
Inputs
Outputs
Property Name
 
Boolean: Toggle Value
On Label
Off Label
Value
Adds a custom on/off toggle that will be seen on the microcontroller's property panel when placed on a vehicle
This acts as a Constant On Signal when enabled. The On Label is what is displayed in the properties if it's enabled, and vice versa for the off label. Value is its default state.

Property Number
Properties
Inputs
Outputs
Property Name
 
Number: Set Value
Value
Adds a custom number input that will be seen on the microcontroller's property panel when placed on a vehicle
This is just like a Constant Number, except you con't need to open the microcontroller to edit its value.

Property Slider
Properties
Inputs
Outputs
Property Name
 
Number: Slider Value
Min Value
Max Value
Value
Adds a custom slider that will be seen on the microcontroller's property panel when placed on a vehicle
Like the Property Number, except displays as a slider the user can drag around. Unlike a Property Number, the minimum and maximum value can prevent a user from entering a number that would break the logic connected to the slider, acting as a built-in clamp. The Increment is how sensitive the slider is, or how much each 'tick' of the slider increases or decreases the output value. Value is the default position of the slider.

Property Dropdown
Properties
Inputs
Outputs
Property Name
 
Number: Selected Value
Default (checkbox)
Label
Value
Adds a custom dropdown list that will be seen on the microcontroller's proprty panel when placed on a vehicle
Naughty typo on 'property' there SW devs, only I'm allowed to make typos.
Property Dropdown can be a bit confusing at first. This logic allows a user to select from one of several numbers to output, but the numbers are pre-determined and are associated with a text label to help the user determine what selecting the number will do.
Clicking the blue plus button adds properties, and the blue X will remove a property. The list is all of the properties currently in the dropdown list, while the checkbox on the left sets which property will be selected by default. 'Label' is how the user will see the property in the drop-down, while 'value' is the number associated with the label.
For example, you have a linear speed sensor and a Property Dropdown connected to a function block, and you want to use the drop-down to allow the user to convert the speed sensor into either miles per hour, kilometers per hour, knots, or something else. You would enter the numbers needed to multiply for the conversions and label each one what the conversion is to.



Property Text
Properties
Inputs
Outputs
Property Name
Value
Adds a custom text input that will be seen on the microcontroller's property panel when placed on a vehicle, for showing player-defined text within a lua script.
While all properties can be referenced in any LUA Script within a microcontroller, the Property Text is specifically designed for LUA Script. If LUA Script is used to output a string of text to a monitor then the Property Text can be used to specify what the text should say.

Tooltip On/Off
Properties
Inputs
Outputs
Property Name
Boolean: Display Signal
On Label
Off Label
Display
Displays an on/off signal on this microcontroller's tooltip when it is looked at by the player on a spawned vehicle.
Mostly used for debugging, when a player looks at the microcontroller directly they will see any active tooltips associated with it. The property name will be the 'name' of the tooltip while the labels are how people will see the state of the tooltip's input node. The On label will be colored green while an Off label is colored red. This tooltip can be set to only display one of its two states, or always.

Tooltip Number
Properties
Inputs
Outputs
Property Name
Number: Display Number
On Label
Boolean: Is Error
Off Label
Display
Displays a number on this microcontroller's tooltip when it is looked at by the player on a spawned vehicle.
The Property Name is the label the player will see the number. The 'Is Error' input can be used to determine if the tooltip is visible, or it can always be visible. The number displayed will be a green color unless the Is Error input is on, in which case it will appear red.
Composite Logic
Composite is essentially logic that can hold up to 32 boolean and 32 number signals inside a single signal. These are broken up into 32 'channels', which is used to determine what signal within the composite to look at. Composite is commonly used for Instrument Panels and Radios that do not have room to accept 64 different inputs unless encoded into a composite signal. It can also be used to send signals to other vehicles via radio or various connectors.

Composite Write (On/Off)
Inputs
Outputs
Composite: Composite Signal
Composite: Modified Composite Signal
Boolean: Input ‡
Number: Start Channel
‡There can be up to 32 inputs, numbered sequentially
Writes up to 32 on/off signals to a composite link in a single logic tick. Only connected channels will be modified. The number of inputs and channel to begin writing at can be configured.
In order to send a composite signal you need to encode information into it. By default the Composite Write has one input set to channel 1. If the number of channels are changed in the properties window then more inputs will be added in sequence below the first, allowing multiple signals to be encoded at a time. The Start Channel can be increased if you are trying to only write to specific channels, or you can use a number input to determine which channel the first input starts at. The Composite Signal input can be used to daisy chain multiple Composite Writes together. Note that only channels that receive an input of some sort will actually be written.

Composite Write (Number)
Inputs
Outputs
Composite: Composite Signal
Composite: Modified Composite Signal
Number: Input ‡
Number: Start Channel
‡There can be up to 32 inputs, numbered sequentially
Writes up to 32 numbers to a composite link in a single logic tick. Only connected channels will be modified. The number of inputs and channel to begin writing at can be configured.
This is exactly the same as the Composite Write (On/Off) except for numbers. Numbers are stored in the same 32 channels that on/off signals are transmitted, however since inputs can only read either a boolean or number there isn't any conflicting overlap.

Composite Read (On/Off)
Inputs
Outputs
Composite: Composite Signal
Boolean: Read Value
Number: Start Channel
Reads the on/off value from a selected channel of a composite input.
So you have a fancy composite signal, which is all well and good, but now you need all that information back in a usable form. Plug the composite into one of these, select which channel you want to read from, and you have your signal back the way you left it. Instrument Panels can also use switches and buttons to output on/off signals and a Composite Read is the only way to decode that information outside of LUA Script. Instead of reading a specific channel, a number input can be used to determine what channel is read.

Composite Read (Number)
Inputs
Outputs
Composite: Composite Signal
Number: Read Value
Number: Start Channel
Reads the number value from a selected channel of a composite input.
This functions exactly like its on/off counterpart, except it will decode numbers instead of booleans.

Composite Switchbox
Inputs
Outputs
Composite: First Signal (On)
Composite: Switched Signal
Composite: Second Signal (Off)
Boolean: Switch Signal
Outputs the first input composite when receiving an on signal, and the second when receiving an off signal.
Works just like all of the other switchboxes, only this time it's dealing with composite signals.

Number to Composite Binary
Inputs
Outputs
Number: Number to Convert
Composite: Binary Signal
Converts a number (rounded) to binary and outputs the bits as composite on/off signals.
In theory this lets you input a number and convert it into on/off signals on each of the composite signal's 32 channels, which can be useful if you want to write something other than numbers to an Instrument Panel's 7 segments. In practice I'm fairly confident this is broken. ¯\_(ツ)_/¯

Composite Binary to Number
Inputs
Outputs
Composite: Signal to Convert
Number: Encoded Number
Reads the on/off signals of a composite link and encodes them in the bits of an output number.
Does the opposite of the Number to Composite Binary, in that the on/off signals on all 32 channels of a composite signal are converted into a single Number. Unfortunately I can't get this to function correctly either.
41 Comments
Zulban  [author] Nov 15, 2024 @ 6:42am 
Honestly my creations were about the same, mostly basic functions and nothing too terribly fancy. The thing that made them special was that I made them myself, and that was one of the most rewarding things about playing. Making an automatic transmission that doesn't stall a boat is about the most complicated thing I remember making, and I sort of did similar for a truck but it wasn't nearly as good functionality wise (it's much more difficult because of the wheels constantly having grip with the road as opposed to a boat propeller which just floats through water).

Hopefully the guide's at least given you some insight to make something you can be proud of to say you did it yourself, that was the whole reason I made this to begin with.
Patates_fregides Nov 15, 2024 @ 3:12am 
Thanks for the guide, It's almost perfect. I'm kind of stupid and for many things I really need a practical example otherwise I don't get it.. . .

Is the problem I have with this game, a lot of the stuff I don't know for what it is used. And at the end my creations are little boats that can do basic stuff.
Zulban  [author] Mar 15, 2024 @ 1:50pm 
If you have discord then the people on the official discord will probably be able to give you better help than I can. I'm not actually an expert with logic, I just happened to make this guide since nobody else felt like making it.
Zulban  [author] Mar 15, 2024 @ 1:48pm 
I'll try to explain as succinctly as possible. Latches will activate their output when its input receives a signal and it will 'latch' on, like a light switch being turned on. It will stay on no matter what. It will only turn off when the 'reset' input gets a signal, turning the latch or 'light switch' off. In this manner you can keep whatever the latch is activating (in this case a channel hopper) until you reset it.

For the channel hopper, you'll want something that will read the current channel's signal strength and if it's 0 it will go to the next channel. An easy way to do this is to pulse an up/down counter to go up by 1 and read that as the current channel being read. Once a signal greater than 0 is found a signal is sent to 'reset' the latch and whatever channel the up/down counter is reading on the up/down counter is the channel with a signal. Once the up/down counter exceeds channel 100 you'll want to reset it to 0 so it can start from the beginning.
Silver Mar 15, 2024 @ 12:29pm 
My main problem as well is How do you make the channels hop?
Silver Mar 15, 2024 @ 12:17pm 
How do latches work......?
Zulban  [author] Mar 14, 2024 @ 5:10pm 
I never got too involved in radio signals, but sounds like you want something that will activate a latch to start the channel hopping. It will tune to a channel, then if the signal strength is greater than 0 it de-activates the latch, keeping it on that channel. Sorry but I don't have much experience with it but that's probably how I'd do it. It would probably take a while to flip through all those channels.
Silver Mar 14, 2024 @ 4:19pm 
I'm trying to make an RX directional signal thingy that can steal signals. I want it to go through 1-100 for the frequency and when it finds a signal strength, it stops at that signal. I have no idea how to do so though.
Zulban  [author] Nov 8, 2023 @ 2:13pm 
You memorize a handful of the most common ones, such as the and/or gates, threshold gates, mathematics, and switchboxes. Then when you need something beyond that you look it up.
user Nov 8, 2023 @ 9:29am 
but how am i suppose to know logic if i dont remember it