Logic Blocks

From Trailmakers Wiki
Jump to navigation Jump to search

Overview

Logic Blocks are a group of blocks which allow to automate tasks, create more advanced controls for vehicles, and process information. They can be divided into sensors, which create outputs when some external conditions are met, and logic gates, which create outputs when a condition of their inputs is met. Sensors are either 1x1x2 (distance, altitude, and speed senors) or 1x2x2 (angle sensors and compass) sized blocks. Logic gates are 1x1x2 sized blocks. On one of the 1x2 sides, logic gates have a display depicting 2 arrows and a symbol representing their type. Every logic block weighs 0.6 kg, except the Angle Sensor and Compass, which weigh 1.2 kg (in all cases, the same as a normal structural block of their size would weight).

BIconOn.jpg AIconOff.jpg
BIconSeat.jpg BIconFrame.jpg BIconPropulsion.jpg BIconWheels.jpg BIconMechanical.jpg BIconAero.jpg
BIconWeapons.jpg BIconLift.jpg BIconTubes.jpg BIconBalance.jpg BIconGadgets.jpg BIconLogic.jpg



How Logic Gates Work

There are 9 types of logic blocks in the game:

  • AND Gate
  • OR Gate
  • XOR Gate
  • Distance Sensor
  • Speed Sensor
  • Altitude Sensor
  • Gravity Sensor
  • Angle Sensor
  • Compass

Logic Gates work by providing an output based on the inputs they get. These Logic Blocks can also be controlled directly with a Green (Positive) and a Red (Negative) keybind inputs. Like other blocks, they also have fields for Timing and Delay.

The output of a logic gate is *not* the output you specify in the editor while building. The output of the gates is calculated by adding all the inputs together, rounding down to 1 if it is above, or up to -1 if it is below, then multiplying this value by their "output value". Some blocks, like engines or mechanical blocks, use this value to determine the strength of their activation. In general, an output of 0 is the same as no (off) output (although this is not always necessarily the case[1]), and an output different from 0 is an on input.[2]

AND Gate

  • The AND Gate only produces an output if all of the inputs are on.[3]
  • Example 1: The AND Gate with two inputs receives a 1 and a 0. Because only one of the inputs is a 1, the AND Gate will not send an output. When it receives a 1 and a 1, it will send its output to whatever blocks that are marked to receive it.
  • Example 2: An AND Gate with 3 inputs receives a 1, -0.5, and -0.5. Because adding the inputs together equals 0, the AND gate outputs nothing[4].

OR Gate

  • The OR Gate only produces an output if any of its inputs are on.[3]
  • Example 1: An OR Gate with 3 inputs receives a 1, 1, and 0. Because one of the inputs sends a 1, the OR Gate will send its output. If all of the inputs were 0, it would not send any output.
  • Example 2: An OR Gate with 3 inputs receives a 1, -0.5, and -0.5. Because adding the inputs together equals 0, the OR gate outputs nothing[4].

XOR Gate

  • The XOR Gate only produces output if exactly one input is on.[3]
  • Example: An XOR Gate with 3 inputs receives a 1, 1, and 0. Unlike the OR Gate, the XOR Gate will not send its output because the more than a single input is a 1. If the inputs were 0, 0, and 1, the XOR Gate would send its output.
  • Note that this is not necessarily the case with real-world binary logic, as with actual binary logic, an XOR Gate with more than 2 inputs can either produce the behavior described here or send an output if an odd number of inputs are active.

Distance Sensor

  • The Distance Sensor sends an output when the distance between the sensing side of the block and another block or object come within a set distance.[5]

Speed Sensor

  • The Speed Sensor sends an output when the speed of the block reaches a set speed in the direction pointed by it.[6]

Altitude Sensor

  • The Altitude Sensor sends an output when the altitude of the block reaches a certain altitude relative to the water level.[7]

Gravity Sensor

  • The Gravity sensor sends an output when the gravity experienced by the build reaches a set amount.[8]

Angle Sensor

  • The Angle Sensor sends output when the angle of the block reaches a set amount relative to the up direction.[9]

Compass

  • The Compass sends output when the direction the block is facing falls within a set angle relative to the north direction.[10]

Math Blocks

Math blocks are a new type of logic block added in the 1.9 Update on August 15th, 2024. Math blocks take numeric inputs and perform operations to get an output, either numeric or boolean. They are the only kind of block that does not clamp the sum of their inputs to the [-1,1] range. As of August 2024, there are 4 math blocks:

  • Comparison Logic Gate
  • Accumulator
  • Number Display
  • Hue Light Panel

Comparison Logic Gate

  • The Comparison Logic gate takes the sum of its inputs and performs a boolean operation. Such boolean operations include equal, not equal, more than, more than or equal, less than and less than or equal.

Accumulator

  • The Accumulator block holds and outputs a value that can be clamped in the block configuration menu and manipulated with its inputs. The value is visually represented by a bar, which is displayed green when the value is positive and red when negative.

Number Display

  • The Number Display block displays the sum of its outputs, with optional rounding.

Hue Light Panel

  • The Hue Light Panel changes its color depending on its input.
    • When the input is 0, the block does not emit any light.
    • When the input under 0, the block emits light in a grayscale gradient up until -1 (white), where it is clamped.
    • When the input is over 0, the block emits light in a hue gradient up until 1, where it cycles back to red.

Arithmetic Logic Gate

  • The Arithmetic Logic Gate performs numerical operations with the sum of its inputs and a constant. Such numerical operations include addition, subtraction, multiplication and division.

Connecting Inputs and Outputs

Logic Blocks can be connected to any other block that can be controlled with input, including other Logic Blocks. To have a Logic Block control another block, Click the gear icon on the logic block and click the check box on the block that you would like it to control.

Tips

  • A single Logic Block can control multiple blocks at a time. If your vehicle has a lot of Mechanical Blocks to control at once, you can set them to be controlled by a single logic block instead to avoid needing to modify the controls and timing of each block.

References

A more in depth explanation about logic blocks, in which this page is partially based on, can be found here: Main page, Direct download

  1. On the steam version, this is always the case. On other versions, the truthness and output values are separate, which makes this only be the case for blocks that use the output value except logic gates.
  2. For more information, read the "Output Value" section of the Logic Blocks Guide
  3. 3.0 3.1 3.2 For more information, read the "Logic Gates" section of the Logic Blocks Guide
  4. 4.0 4.1 This is only the case on the steam version. On other versions, this actually results in an output with a value of 0
  5. For more information, read the "Distance Sensor" section of the Logic Blocks Guide
  6. For more information, read the "Speed Sensor" section of the Logic Blocks Guide
  7. For more information, read the "Altitude Sensor" section of the Logic Blocks Guide
  8. For more information, read the "Gravity Sensor" section of the Logic Blocks Guide
  9. For more information, read the "Angle Sensor" section of the Logic Blocks Guide
  10. For more information, read the "Compass" section of the Logic Blocks Guide