Guide:Logic Gates

From Terraria Wiki
Jump to: navigation, search

To new players or players who have never tinkered with wiring before, logic gates may seem complicated. Logic gates, however are very useful tools in Terraria for anyone wanting to construct advanced wiring creations. This guide assumes you already have basic knowledge of wiring. But, if you don't you can learn more about wiring here.

Basic Logic Gate Functions[edit | edit source]

There are six different kinds of logic gates: AND, OR, XOR, and their inverses NAND, NOR and XNOR. Each gate only turns on when specific conditions are met, and turns off when these aren't met. The AND gate, for example, only turns on when all connected lamps are on, while the OR gate simply requires at least one of its lamps be on to turn on, and won't turn off until all connected lamps are off. X stands for "exclusive," so XOR, or "exclusive OR" only turns on when exactly one connected lamp is on. The "N" on the inverse gates stands for NOT. While thinking of them as the opposite of their basic gates will generally work, they specifically turn off when their base gates would turn on and vice versa. The OR gate turns on when at least one lamp is on, and off only when all lamps are off. The NOR gate, as the inverse, turns on when no lamps are on, and off when at least one lamp is on. The XNOR gate turns off when exactly 1 lamp is on, and turns on when any number of connected lamps other than 1, including 0, are lit.

AND Logic Gate[edit | edit source]

Example of the AND Logic Gate.

There are many things you can do with the AND Logic Gate. The AND Gate reacts only when all inputs are true, so it can be used to restrict access to a particular area unless a player has flipped specific switches throughout the world. It's also great for situations where more than one goal needs to be achieved before a player can move on.

Another use for the AND Gate is wire changing, that is the changing of the color of the wire. AND Gates are useful where one wire color must be used for the input, but another used for the output. A good example is a complicated teleporter hub that needs to be wired to a teleporter where other wires interfere. If you just have one input, the input value and output value will always be the same, (true or false, off or on.)

A third use for AND Gates is for something a player doesn't want happening before other things happen. For example, a player wouldn't want the inner door of their airlock in their underwater base to open before the water was pumped out AND the outer door was closed. Using an AND Gate, the player can wire it to only open the inner door if there isn't any water in the chamber AND the outer door is closed. This can be done using switches, but using the AND Gate, it becomes more streamlined.

A fourth use for AND gates is filtering signals from other sources. Consider a large, complicated statue farm. It would be possible to control it with a series of timers, but this becomes less useful if an engine is used to increase the trigger rate. In this case, without the use of logic gates, the options are to trigger all the statues at once with the engine, or to build an engine for each set of statues. Instead, AND gates can be employed. By sending the engine's signals through an AND gate also wired to a switch, no signals from the engine will be passed through to the statues until the switch is thrown.

OR Logic Gate[edit | edit source]

OR Logic Gates are useful when you want something to happen only after one of the inputs are triggered. For example in an adventure map, if you want players to only select one room, you may wire up an OR Gate to some pressure plates so that once they enter a room, they may still backtrack to the previous room, but not to the rooms they didn't choose.

The big idea with OR Gates is having to make a choice, while at the same time, shutting off other options once that choice has been made. However, OR Gates can be used when the player only has to complete one task, out of many, such as one parkour path out of four, in an adventure map for example. OR Gates can also be useful outside of adventure maps, for instance, if the player wants to wire an OR gate so that when day shifts to night or when an enemy comes into range of your defences, they turn on. This would be useful for discouraging any slimes or other daytime baddies from attacking you.