Logic Blocks

## Overview

Logic Blocks are 1x1x2 sized blocks, except for the Angle Sensor and Compass which are 1x2x2, that simulate the action of Logical Gates. On one of the 1x2 sides, they have a display depicting 2 arrows and a symbol representing their contained Logic Gate. These blocks can be used to create automation and more advanced controls for vehicles. Every logic block weighs 0.6 kg, except the Angle Sensor and Compass, which weigh 1.2 kg.

## How Logic Gates Work

There are 8 types of logic blocks in the game:

* AND Gate
* OR Gate
* XOR Gate
* Distance Sensor
* Speed Sensor
* Altitude Sensor
* Angle Sensor
* Compass

Logic Gates work by providing an output based on the input it gets. These Logic Blocks can also be controlled directly with a Green (Positive) and a Red (Negative) keyboard 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 the "output." This means both AND Gates and OR Gates can output values of zero.

#### AND Gate

* The AND Gate only produces its output if all of the inputs are not zero.
* Example: 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 its 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.

#### OR Gate

* The OR Gate only produces its output if any of it inputs are not zero.
* Example: 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.
* Note that, like the other gates, the output of the OR Gate 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 the "output."

#### XOR Gate

* The XOR Gate only produces output if exactly one input is not zero.
* 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 the case with real-world binary logic, as with actual binary logic, an XOR Gate will send its output if an odd number of inputs are active.

#### Distance Sensor

* The Distance Sensor sends output when the distance between the sensing side of the block and another block or object come within a set distance.

#### Speed Sensor

* The Speed Sensor sends output when the speed of the block reaches a set speed.

#### Altitude Sensor

* The Altitude Sensor sends output when the altitude of the block reaches a certain altitude.

#### Angle Sensor

* The Angle Sensor sends output when the angle of the block reaches a set amount.

#### Compass

* The Compass sends output when the direction the block is facing falls within a set angle.

#### 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.