• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

An Official Introduction to Terrarian 1.3.1 Wiring & Mechanics

Yoraiz0r

Lead Developer
Re-Logic
logo.png



Introduction - Wiring in Terraria
Hello everyone!

I wrote this thread with the purpose of giving everyone an approachable starter guide centered around wiring in Terraria. I hope you will enjoy reading through it and that it will open your eyes to the possibilities that wiring in Terraria provides!

Terraria is a game with 3 primary goals: Dig, Fight, Build!

The focus of this thread is to give you some guidance on building - more specifically, the wiring and mechanical side of building in Terraria. Wiring in Terraria refers to using certain triggers, wires and devices to build automated or advanced contraptions to accomplish a wide array of tasks and functions. Using the Terraria wiring system, you can do many things such as, but not limited to:
  • Using automatic doors that only open or close for players
  • Placing street lights that only turn on at night
  • Defending your home from monsters with a variety of traps
  • Advanced machines limited only by your imagination - from animated fountains to player accelerators to digital displays and much, much more!
The list could go on and on - the possibilities are endless - so without further delay, let's begin your journey to understanding wiring in Terraria!

top
kdcROYP.png


Start Here First: Prerequisites to wiring

So, as with most things in Terraria, you have to explore your world in order to gain access to wiring. Not sure where to go? No worries, just follow the steps below and you will be ready to start building clever Terrarian machines in no time! In order to begin wiring in Terraria, you will need to...
  • Go to a certain ominous place at night
  • Defeat the evil guardian blocking its entrance
  • Wander around inside, until you find this fair maiden
  • Save her, so she can sell you her quite reasonably priced tools required to place and remove wires - a critical component to building machines in Terraria!
  • It is probably wise at this point to build a room for her in your establishment so she that may live in a place that is easy to access
  • Once you have completed the adventure outlined above, you will then be ready to begin freely exploring messing all that wiring in Terraria has to offer!

top
kdcROYP.png


Back to Basics: Tools, Triggers, Devices, and Traps
After you've met the requirements necessary to unlock the wiring tools, it's time to dive in and learn more about what is possible and how it all works!


The Basic Workflow of Wiring
Setting up a simple wired machine in Terraria is really quite easy. Once you have the necessary Tools, a Trigger, and a Device you simply follow the three steps below to get everything hooked up:

  1. Place the device you want to manipulate
  2. Place a trigger which will manipulate it
  3. Connect the two with wire
After the mechanic has settled in her room in your home base, she will offer a variety of items for you to purchase. These items are split to three categories: tools, triggers, and devices - let's will go through each of them individually to explore how they work.
Note: The list isn't full - just introductory - You can also find or craft some of these, not everything is store-bought!


index.php

Tools

The Tools category covers the items and supplies that you will need to lay wires to connect all of your machinery together.
  • BR0rHC1.png
    Wires - these are supplies used for wiring, they can only be placed with a wrench.
  • WaUrgo5.gif
    Wrenches - these come in four colors, placing wire that matches their color as you use them.
  • IhPQjX6.png
    Wire Cutter - this tool removes wires you previously placed, letting you pick it up and place it in a different spot or as a different color.
  • 1oxaKIw.png
    Junction Box - these are placeable, and they prevent wires of the same color from intersecting. You can also hammer these into different shapes.

index.php

Triggers
Items you find in this category are always placeable, and are able for you to interact with in a certain way. When used, they will affect all devices connected to them with wire. The form of interaction changes between each of them, and the act of interaction is referred to as triggering - hence the name Triggers.
  • PnoO7Kh.gif
    Pressure Plates - these trigger whenever stepped on by a player or an NPC.
  • YVllQjF.gif
    Timers - these trigger each X seconds, X being the number shown on them; they can also be turned on/off via direct interaction.
  • KZHkGiK.gif
    Switches / Levers - these only trigger when directly interacted with. (with exception to Detonators, which can be jumped on to trigger)

index.php

Devices

Items you find in this category are always placeable, and when affected by wire (via a Trigger) their function will be activated.
  • MbFGmPW.gif
    Light Sources - when activated they turn on/off.
  • IM5Te1k.png
    Music Boxes - when activated they play/stop their music.
  • lcB6qoo.png
    Doors - when activated they open/close.
  • iTHqni2.gif
    Statues - when activated they may spawn what they look like!
  • ffykOQD.gif
    Inlet/Outlet Pumps - if an inlet & an outlet are activated by the same wire color, liquid will move from the inlet to the outlet.
  • l5K9rCc.png
    Actuators - these are placed over common blocks, when activated they "Actuate/Deactuate" their block, letting you pass through it.
There are many other Devices for you to discover in Terraria! Some of our favorites include: Water Fountains, Teleporters, Fireworks!

index.php

Traps

Items you find in this category are devices often found while exploring the world that can harm you and NPCs alike. To avoid ruining the surprise for newcomers to Terraria - this section only lists one of the more commonly-encountered traps, but these instructions will work for any trap!
  • Traps work exactly like other Devices - requiring a Trigger and a wired connection to set them off.
  • Many of the traps in Terraria may be rotated when hit with a hammer.
  • After activation, there is a delay until it can be activated further - usually lasts 1~3 seconds.
The
VnTN8GS.png
Dart Trap - most commonly found underground, shoots a poison dart at the direction it is facing whenever activated, for example.


kdcROYP.png

Giving it a Try: Some Basic Wiring Examples

EXAMPLE #1: Automatic Door

After knowing what tools, triggers, and devices you have, you can now put them to work! Following The Basic Workflow, let's make an automatic door!
The steps to making this clever time-saving machine are quite simple, let's see...
  1. Place the device - in this case a
    lcB6qoo.png
    Wood Door
  2. Place a trigger - in this case a
    PnoO7Kh.gif
    Pressure Plate
  3. Connect the two with
    BR0rHC1.png
    Wire
  4. Voila! You are the proud owner of one Automatic Door!
Here's a slow-mo of these steps in action
tLKa39v.gif

index.php

EXAMPLE #2: Automated Defenses
After making a simple automatic door, you can probably tackle something more advanced, such as an automatic defense for your home. Following The Basic Workflow again, we can wire up a defensive trap like so...
  1. Place the device - in this case a
    VnTN8GS.png
    Dart Trap
  2. Place a trigger - in this case we will use a
    KZHkGiK.gif
    Switch / Lever and a
    YVllQjF.gif
    Timer.
  3. Connect the three with
    BR0rHC1.png
    Wire
Here's a slow-mo of these steps in action
nW4EaES.gif

index.php

EXAMPLE #3: Simple Toggled Lights
For convenience, one common use of wires is toggled lights for your base, let's try that out.
Following The Basic Workflow once more, we can wire up a light fairly easily.
  1. Place the device - in this case a
    MbFGmPW.gif
    Torch
  2. Place a trigger - in this case we will use a
    KZHkGiK.gif
    Switch / Lever.
  3. Connect the two with
    BR0rHC1.png
    Wire
Here's a slow-mo of these steps in action
j7EZeXe.gif

top
kdcROYP.png


Taking it to the Next Level: New & Advanced Triggers - Sensors & Logic Gates
In the previous section we covered all the basic usage elements of wires, most of which were already available in Terraria for years. However, the 1.3.1 Update brings with it a fresh set of possibilities via all new Trigger types! Now that you understand the basic elements of Wiring, we can learn to use more these advanced triggers - such as Sensors & Logic Gates.
Sensors
The 1.3.1 Update has added Sensors - These fit into the Trigger category, as they trigger based on a specified condition.
  • yeK8eo1.png
    Logic Sensor (Day) - these only trigger once an in-game day starts, at 4:30AM.
  • vXj7sJA.png
    Logic Sensor (Night) - these only trigger once an in-game night starts, at 7:30PM.
  • TZqzO2f.png
    Logic Sensor (Player Above) - these trigger On Condition Change, the condition being "there is at least one player over the sensor".
I'd like to emphasize that
TZqzO2f.png
Logic Sensor (Player Above) can trigger from two cases - both when a player enters its detection range AND when leaving that range.

index.php

Logic Gates
Prior to the 1.3.1 Update, complex machines in Terraria required quite massive structures in order to perform the Logic functions central to their operation. This update greatly simplifies that process and makes it so much more accessible: without further ado, I give you... Logic Gates.
phcyORP.png
1yhtKhw.png
ByDkg68.png
xukQ43v.png
m1Y2Yq6.png
6rXGOX6.png


To understand how Logic Gates work, you need to have a good understanding of "binary". Binary is an adjective that means "having only two states" (ON / OFF, for example) and is critical to all modern computing devices.

Logic gates are devices that take multiple binary inputs & compare them against a condition. For example, this
phcyORP.png
Logic Gate (AND) compares to the condition "this AND that are ON.".

So how do you feed input into logic gates? by using
BHfljm9.gif
Logic Gate Lamps.
BHfljm9.gif
Logic Gate Lamps are devices that have an ON/OFF state, can only be placed above gates or other lamps & on activation they toggle their state.

Lastly, let's look into the gates themselves.
Logic gates - these fit into the Trigger category, as they trigger based on their conditional state's changes.
  • phcyORP.png
    Logic Gate ( AND ) - triggers on condition change - the condition is "All inputs are ON"
  • ByDkg68.png
    Logic Gate (NAND) - triggers on condition change - the condition is "NOT all inputs are ON"
  • 1yhtKhw.png
    Logic Gate ( OR ) - triggers on condition change - the condition is "At least one input is ON"
  • xukQ43v.png
    Logic Gate ( NOR ) - triggers on condition change - the condition is "NOT even one input is ON"
  • m1Y2Yq6.png
    Logic Gate ( XOR ) - triggers on condition change - the condition is "Only one input is ON"
  • 6rXGOX6.png
    Logic Gate (NXOR) - triggers on condition change - the condition is "Total ON inputs count is NOT 1"

index.php

The Gated Workflow
It is important to note that if you intend to use logic gates, your basic workflow changes.
  1. Place the device you want to manipulate
  2. Place the Logic Gate of the condition you wish to check & the required amount of logic gate lamps for it
  3. Place at least one additonal trigger per Logic Gate Lamp
  4. Connect the Logic Gate to the device with wire
  5. Connect each Logic Gate Lamp to a trigger using wires of different colors
Confused? Don't be! Let's look at a few examples to help it all come together and make sense.

kdcROYP.png

Putting Binary to Work: Logic Gate Examples
EXAMPLE USAGE #1 - AND Gate

Following The Gated Workflow, let's make a "secret passage" that opens up if you flip two levers on. This is actually pretty simple, check it out...
  1. Place the device - in this case a few
    l5K9rCc.png
    Actuators
  2. Place logic gate and lamps - in this case an
    phcyORP.png
    AND Gate & two
    BHfljm9.gif
    Logic Gate Lamps
  3. Place triggers for each lamp, in this case two
    KZHkGiK.gif
    Switches / Levers
  4. Connect the logic gate to the actuators with
    BR0rHC1.png
    Wire.
  5. Connect each logic gate lamp to a lever with differently colored
    BR0rHC1.png
    Wire.
Here's a slow-mo of these steps in action
EwxUTBc.gif

index.php

EXAMPLE USAGE #2 - OR Gate
Often when making games or adventure maps, there's a need to create conditions that can only be toggled in one direction, such as "finished a quest" or "solved this puzzle".
Following The Gated Workflow, we can make a gate that can only turn on once and then stay on forever, let's do that!
  1. Place the device - in this case a
    lcB6qoo.png
    Door will be good.
  2. Place logic gate and lamps - in this case an
    1yhtKhw.png
    OR Gate & two
    BHfljm9.gif
    Logic Gate Lamps
  3. Place triggers for each lamp, in this case we only need one
    KZHkGiK.gif
    Switch / Lever, as the gate would connect itself to the other lamp!
  4. Connect the logic gate to the door & one of the logic lamps with
    BR0rHC1.png
    Wire.
  5. Connect the other logic gate lamp to a lever with differently colored
    BR0rHC1.png
    Wire.
Here's a slow-mo of these steps in action
MFX5d8W.gif
The result is that the door will open once and stay opened forever after 1 flick of the lever, because the conditions for it to remain open are "flicked the lever OR did the gate activate at least once" - which happens thanks to the lever flick!​

index.php

EXAMPLE USAGE #3 - XOR Gate
There's some situations where you'd like to detect if a choice has been made out of multiple ones, and if so - which choice?
For example, of choosing between GOOD or EVIL, you want to give someone the choice and not let them proceed until they've picked their side.
Following The Gated Workflow, it can be done using XOR gate with any number of choices you'd like.
  1. Place the device - once again a
    lcB6qoo.png
    Door. (and some torches for visual feedback)
  2. Place logic gate and lamps - in this case an
    m1Y2Yq6.png
    XOR Gate & two
    BHfljm9.gif
    Logic Gate Lamps
  3. Place triggers for each lamp, two
    KZHkGiK.gif
    Switches / Levers.
  4. Connect the logic gate to the door with
    BR0rHC1.png
    Wire.
  5. Connect the each logic gate lamp to a lever with differently colored
    BR0rHC1.png
    Wire, and place a torch on the path of each wire color.
Here's a slow-mo of these steps in action
fKKD3G3.gif
top
kdcROYP.png

 
Last edited by a moderator:

KinfThaDerp

Plantera
Brain blown by the simplest mechanics that terraria didn't have, now i need to find the mechanic... Skeletron, here i come!
 

Niranufoti

Plantera
So wait, the polyadic (multary) XOR gate isn't actually an XOR gate, but a one-hot detector? To get an actual polyadic XOR, we have to build our own diode?
 
Last edited:

Reactorcore

Terrarian
I learned a lot from this guide, thank you! :)

For those who have unstable or no internet, could this be included with the game as a pdf in the installation folder?
You know, for official reference, since there are no tutorials or otherwise available to learn this within the game itself.
 

DicemanX

Brain of Cthulhu
Excellent guide @Yoraiz0r! I was just curious - would you consider posting a duplicate thread in the T-MEC forums so we can sticky it? I imagine that the info will be useful for a long time to come. We could also just link this thread of course, but it's easier to have the visuals and text in the post itself.

Fine work on the logic gates as well. Prior to 1.3.1 we needed to use separate reset systems to revert the outputs back to their original states before sending signals through the gate again (to prevent the gates from working as mere toggles), but the 1.3.1 gates have a really elegant "reset" by sending a pulse when the logic gate square boxes turn off or turn on.

I was nevertheless curious - did you have something specific in mind when designing the N versions of the gates? Since the outputs are arbitrarily determined in a pulse-based system, it is possible to switch over from, say, an AND gate to a NAND gate merely by changing the definitions of the outputs or by reversing their state (switching a off torch to the on state, actuating or deactuating a block, opening or closing a door etc.). Did you foresee a situation where a NAND gate would need to be used over an AND gate? If not, I suppose the AND and NAND versions are still a good idea if one wanted to build Terraria electronics more faithful to real world electronics systems :).
 

Niranufoti

Plantera
I was nevertheless curious - did you have something specific in mind when designing the N versions of the gates? Since the outputs are arbitrarily determined in a pulse-based system, it is possible to switch over from, say, an AND gate to a NAND gate merely by changing the definitions of the outputs or by reversing their state (switching a off torch to the on state, actuating or deactuating a block, opening or closing a door etc.). Did you foresee a situation where a NAND gate would need to be used over an AND gate? If not, I suppose the AND and NAND versions are still a good idea if one wanted to build Terraria electronics more faithful to real world electronics systems :).
I obviously can't know what the team had in mind doing this, but you have to remember that not everyone gets all of this stuff as easily as people like you and me. I'd assume that most of these are mainly there so things are easier to understand - technically, A & B is equivalent to !(!A | !B), so we'd have only needed one of AND, NAND, OR and NOR. Also, a real XOR gate (addition modulo 2) in a pulse-based system would be the same as a diode with multiple inputs (I'm pretty sure I mentioned that before somewhere), and since a diode could be easily made with any logic gate and just a single logic gate lamp (with at least up to three inputs; haven't checked how exactly the junction thingies work), you could theoretically build all the logic gates using only one of them.
But most people would be intimidated by it if it was that complicated and might not even try understanding it - we wouldn't want that, would we now?
 

Yoraiz0r

Lead Developer
Re-Logic
So wait, the polyadic (multary) XOR gate isn't actually an XOR gate, but a one-hot detector? To get an actual polyadic XOR, we have to build our own diode?
Terraria logic gates let you place as many lamps as you want on them, a XOR gate activates when only 1 lamp is 'on', from all the lamps, I'm uncertain as to what the difference is between a "polyadic XOR" & a "3+ lamps one-hot detector", you'd have to be more specific o_O


Excellent guide @Yoraiz0r! I was just curious - would you consider posting a duplicate thread in the T-MEC forums so we can sticky it? I imagine that the info will be useful for a long time to come. We could also just link this thread of course, but it's easier to have the visuals and text in the post itself.

Fine work on the logic gates as well. Prior to 1.3.1 we needed to use separate reset systems to revert the outputs back to their original states before sending signals through the gate again (to prevent the gates from working as mere toggles), but the 1.3.1 gates have a really elegant "reset" by sending a pulse when the logic gate square boxes turn off or turn on.

I was nevertheless curious - did you have something specific in mind when designing the N versions of the gates? Since the outputs are arbitrarily determined in a pulse-based system, it is possible to switch over from, say, an AND gate to a NAND gate merely by changing the definitions of the outputs or by reversing their state (switching a off torch to the on state, actuating or deactuating a block, opening or closing a door etc.). Did you foresee a situation where a NAND gate would need to be used over an AND gate? If not, I suppose the AND and NAND versions are still a good idea if one wanted to build Terraria electronics more faithful to real world electronics systems :).
For moving/duping the thread - looking into it.

As for designing the N versions - I put more thought into the usability of the logic gates than which gates to add, the N versions are just there for those who want to keep a clear vision of why they use which gate and where.
It is easier to know that you want a NAND or a NOR if they're just red colored and waiting for you rather than trying to remember the purpose of each gate in the long run, clarity's important after all.
 

Dark_Reaper115

Terrarian
FINALLY !!! After all this years my one request is part of the game !!! We have diodes so actually make circuits !!!
I guess im not the only one doing a "mechanic" playthrough... I might add some technological weapons/guns or just be a summoner. After all, if you want machines to do your work, might as well also leave minions do your work.
 

Niranufoti

Plantera
Terraria logic gates let you place as many lamps as you want on them, a XOR gate activates when only 1 lamp is 'on', from all the lamps, I'm uncertain as to what the difference is between a "polyadic XOR" & a "3+ lamps one-hot detector", you'd have to be more specific o_O
According to my sources (i.e. Wikipedia and common sense), polyadic XOR would be "addition modulo 2", that is, the output is 1 if an odd number of inputs is 1. That's what you get when evaluating a chain of A XOR B XOR C XOR ... XOR N in any order. Of course it's useful to have a =1 gate, since as I outlined previously, unless an even number of inputs of the XOR (addition modulo 2) gate are toggled (receive a pulse) at the same time, any change in input causes a change in output (a pulse), so in Terraria's pulse-based system, it's effectively the same as a diode. Still, maybe it shouldn't be called an XOR gate, and the XOR gate should be implemented seperately (if at all).
Also, while we're at suggesting new gates, an "any but not all" gate would be nice as well. Then we'd have three gates that would work the same with two inputs, but work differently at higher levels.
Though, then again, anything other than the current "=1" XOR gate could be constructed rather easily.
 

Noit

Terrarian
Terraria logic gates let you place as many lamps as you want on them, a XOR gate activates when only 1 lamp is 'on', from all the lamps, I'm uncertain as to what the difference is between a "polyadic XOR" & a "3+ lamps one-hot detector", you'd have to be more specific o_O

He means the equivalent of having 2+ inputs for a single gate, "should" be the same as putting multiple 2 input ones in association. For example A AND B AND C is the same as (A AND B) AND C. So A XOR B XOR C should be the same as (A XOR B) XOR C, in your implementation it isn't, for example 1 XOR 1 XOR 1 is 0, but (1 XOR 1) XOR 1 is 1. In order to be like that it should be "An odd number of inputs are ON", and for the XNOR "Not an odd number of inputs are ON" which is the same as "An even number of inputs are ON". This is how is commonly interpreted:
Wikipedia said:
https://en.wikipedia.org/wiki/XOR_gate
Strict reading of the definition of exclusive or, or observation of the IEC rectangular symbol, raises the question of correct behaviour with additional inputs. If a logic gate were to accept three or more inputs and produce a true output if exactly one of those inputs were true, then it would in effect be a one-hot detector (and indeed this is the case for only two inputs). However, it is rarely implemented this way in practice.
It is most common to regard subsequent inputs as being applied through a cascade of binary exclusive-or operations: the first two signals are fed into an XOR gate, then the output of that gate is fed into a second XOR gate together with the third signal, and so on for any remaining signals. The result is a circuit that outputs a 1 when the number of 1s at its inputs is odd, and a 0 when the number of incoming 1s is even. This makes it practically useful as a parity generator or a modulo-2 adder.
 

DicemanX

Brain of Cthulhu
Also, a real XOR gate (addition modulo 2) in a pulse-based system would be the same as a diode with multiple inputs (I'm pretty sure I mentioned that before somewhere)

This was possible to construct in pre-1.3.1 by connecting any number of switches/pressure plates to a wire connected to an output :). So long as there are an odd number of inputs the output is always 1. We now have a dedicated gate for this function, but it might be easier to just use the previous approach.


But most people would be intimidated by it if it was that complicated and might not even try understanding it - we wouldn't want that, would we now?

Yes indeed, it's probably going to be easier for many have all 6 gates at their disposal instead of just relying on 2. In my demonstration videos I'll most likely use the other gates as well even though I really only need the AND gate.
 
Top Bottom