## Contents

## Basic Information[edit | edit source]

The **Math Gate** is a logic gate that can be wired in between activation devices (for example Number Pads, Industrial Number Pads, Sensors, Switches or Pressure Plates) or other logic gates (including Inverter Gates, Flip-Flop Gates, Delay Gates and/or Number Comparison Gates) and other logic gates or activatable wireable objects, for example doors, trapdoors, wicket gates, block phasers, loot spawners, mob spawners, lamps, beacons or fans. As its name implies, it can be used to do basic math operations on its inputs.

**Math Gates take two numbers as an input, and perform on of seven mathematical operations on them: add, subtract, multiply, divide, mod, min, max.**

## How to obtain this Gate[edit | edit source]

Math Gates can be crafted in your Crafting Menu, but only after their crafting recipe has been unlocked for free in your Crafting Menu (that can be opened by typing "q" as the default key).

These gates cannot be obtained from any Creatures or randomly spawning Treasure Chests. They can be bought as part of building kits for customizable Blueprints for QBits. Please note that none of these purchases will unlock the crafting recipe in the Crafting Menu.

## Unlocking the crafting recipe[edit | edit source]

To unlock the crafting recipe for Math Gates for free in your Crafting Menu (to be opened by "q" as the default key), you'll need to craft or obtain:

- one Delay Gate
- one Inverter Gate, and
- one Switch

## How to craft[edit | edit source]

To craft **8** Math Gates at a time in your Crafting Menu, you'll need:

- 2 Magnetite mined from the Fossil layer underground (acessible through Caves) or obtained by killing or pet-harvesting Night Rocksters, Warmworms or Rockzillas
- 2 Stone Slabs made in a Processor from Stone, Limestone or Bedrock
- 2 Stone
- 2 Arcstones obtainable from Keepas of any kind either as loot or pet-harvest

## How to use[edit | edit source]

### General usage[edit | edit source]

To use a Math Gate, it must be placed into the game world and wired to activation devices (or other gates) and one or more receiving wireable object/s like other gates, arc signs, doors, wicket gates, trap doors, lamps, beacons, arc signs or machines.

You can fully rotate Math Gates into all directions by pointing your cursor at them, then pressing and holding R (as the default key) and then moving the mouse while holding down the left mouse button. The chosen rotation angle can be "locked" too by simply typing "r" while looking at an already rotated item, so that all items of the same stack in the chosen quickslot will then face the same direction when being placed.

Like most other placeable items, Math Gates can be painted, with the primary color influencing the color of the gate. It is seemingly not affected by the secondary color. They can also be put into displays, where they will be shown at a reduced size.

Math Gates can be picked up without the need to equip any Power Cells if you match or outrank the permission level of the gate that has been defined by its owner. Of course you won't be able to pick up such objects on game worlds, on player claims or in Adventures where your Permission rank is not sufficient (mainly when you are merely a visitor), which can only be changed by the owner of the game world, the respective claim owner or Adventure creator.

### How to wire[edit | edit source]

To wire Math Gates, equip an Wiring Tool and point your cursor at the Math Gates that you have placed into the world. Their "Receive" Connectors will become visible then and you will be able to connect them to the "Send" Connector of activation devices and/or of other logic gates. Also wire their "Send" Connector to the "Receive" connector of another wireable device, e.g. another logic gate or an activatable object like a door or lamp.

Type "n" (as the default key) to inspect the wiring window of the Math Gates if you wish to type a code word into the receiving arrays that you should then also use in the sending array of the activation device/s to connect them or use non-default trigger settings.

- A Math Gate has two input fields, "Input 1" and "Input 2", an output field, and a dropdown to select the mathematical operation the gate will perform on its inputs. It will send the result of this operation as its output.
- The "Input 1" and "Input 2" fields take event names (when Event is selected from under the field) or numeric values (when Value is selected from under the field) as their values. You will most likely want to connect them to something that sends a numeric output, like Number Pads, Counters, Random Number Generators, Memory Gates and other Math Gates.
- The dropdown allows the selection of the mathematical operation the gate will perform on its inputs.
**Add**will output "Input 1" + "Input 2"**Subtract**will output "Input 1" - "Input 2"**Multiply**will output "Input 1" times "Input 2"**Divide**will output "Input 1" divided by "Input 2" - note that this is integer division, so any decimal places will be dropped (so e.g. 7 / 3 will output 2, and -5 / 2 will output -2)**Mod**will output the remainder of "Input 1" divided by "Input 2", so e.g. 8 Mod 3 will output 2, and -7 mod 3 will output -1**Max**will output the larger one of "Input 1" and "Input 2"**Min**will output the smaller one of "Input 1" and "Input 2"

- While you can wire a Math Gate directly to an activation device such as a door, it is usually more useful to wire it to something that uses numeric input instead of only "true"/"false", e.g.
**Math Gates**, Number Comparison Gates, Arc Signs or Arc Portals. - you can write code words into the arrays for "sends" and "receives" and then use these same code words in the correlating arrays of the activation devices and/or the objects that you want to activate/deactivate
- by clicking on this icon, the Math Gate can be renamed (30 characters). This can be useful for documenting more complex circuits.
- by clicking on this icon, access to the Math Gate can be restricted by changing the permission settings so only players that match or outrank the set permission rank can use or even take the gate

## Trivia[edit | edit source]

- The output of the Math Gate gate is stored as a signed 32-bit integer, which can only hold values between -2147483648 and 2147483647. If the result of your math would be larger than 2147483647, it will overflow and start from -2147483648 again, and vice versa. This is unlikely to be a problem in any practical use of the gate.
- Attempting to divide by 0 will result in the integer max value of 2147483647.