Terraria

Terraria

48 ratings
The Ultimate Community Wiring Guide (Beginner-Advanced)
By ﴾Λ͟rtificial﴿ and 2 collaborators
The no nonsense guide to Terraria wiring! Skip 4 years of college from one simple guide!
3
2
2
   
Award
Favorite
Favorited
Unfavorite
Introduction To Terraria Wiring & Mechanical Engineering
This guide is aimed at sharing the basic principles of wiring to everyone, regardless of skill or knowledge level. Unlike other boring guides, this one keeps it interesting with images, videos, and actual hands-on examples. None of the boring college textbook stuff!

In the beginning of this guide we will be going from the basics, intermediates, then later, moving on to some more advanced mechanics.

This guide was created with the idea that anyone could learn and contribute. If you have a deep interest in expanding this guide, do not hesitate to contact us.
The Concept of a Signal in Terraria
Important Clarification: It's not like electricity in real life. Signals are single, they travel through the wires from, for example, a switch, toggling the state of all items along the way.
Therefore, signals themselves don't have states.

On the gif, a switch is connected to 2 torches with different states, on and off. When clicked, the switch sends a signal which toggles both torches.



The Four Wire Colors

In Terraria there exists four wire colors that act as what you might expect wires to do, carry and emit signals. The four wire colors are the following:
  • Red Wire.
  • Blue Wire.
  • Green Wire.
  • Yellow Wire.

Wires have one simple function and that is to emit a signal. Example from a switch to a light.



Wires of the same color will emit a signal throughout the entire wire.



By using unique wire colors, this allows independent wire paths to overlap without interfering with each other. For many circuits, you may want to keep multiple wires from interacting with each other, so you can simply use different colors.



However in situations where you may need to cross wire colors, you can use another wiring device called the Junction Box.

Basic Components, Triggers, and Devices
Almost every component in Terraria wiring can be divided into 2 categories: Triggers and Devices. Triggers are mechanisms that, when interacted with, emit a signal. Devices are mechanisms that, when a signal is received, do some kind of action, like when Pixel Boxes light up, or some statues spawn enemies, or how dart traps fire darts.

Nearly any interactive object in Terraria can act as a device. More information about them can be found here[terraria.wiki.gg].

Tools:

Wire Cutters: Removes placed wire.

Actuation Rod: Toggles Actuators on and off.


Red Wrench: Places red wire.

Blue Wrench: Places blue wire.

Green Wrench: Places green wire.

Yellow Wrench: Places yellow wire.

Multicolor Wrench: Places and removes any color wire.


The Grand Design: Places and removes all wire colors, as well as actuators.


Basic Components:

Wires: The fundamental part of the wiring system, wires connect different devices. They come in four colors: Red, Blue, Green, and Yellow. Wires of different colors can cross each other without interfering.

Actuators: These devices are attached to blocks and allow blocks to toggle between solid and non-solid states when activated.

Junction Box: Allows wires of the same color to cross without connecting. Can be hammered.

Switches and Triggers:

Triggers send a signal when a unique condition is met. For example, clicking a switch.

Switch: Sends a signal upon right-clicking. Cannot be placed on the ceiling. Essential part of any mechanism.

Lever: Switch equivalent. Can be placed on the floor and on background walls.

Pressure Plates: Sends a signal when pressed down; different colored plates are activated by different types of players, NPCs, and enemies.
  • Triggered by players only ----------------------- Gray, Brown, Blue, Lihzahrd.
  • Triggered by players, NPCs and enemies ------- Red, Green.
  • Triggered by NPCs and enemies ---------------- Yellow.
  • Triggered by players only, then breaks --------- Orange.
  • Triggered by player when stepping on or off it - Weighted Pink, Orange, Purple, or Cyan.
  • Triggered by projectiles or pets ----------------- Teal.

Weighted Pressure Plates: Sends a signal when a player steps on or off it. Can be placed on the floor like furniture.
  • Due to a bug that exists in 1.4.4 and prior, the normal red and green pressure plates can also be triggered by projectiles or pets.


Teal Pressure Plate: Sends a signal when pressed down by projectiles or pets. Can be placed on the floor, ceiling, or side wall, but not on platforms.

Time Sensors: Send a signal when the day/night starts, depending on the logic sensor used.

Player above Sensor: Sends a signal when player enters or leaves the area above it. (The area is displayed when you place the sensor)

Liquid Sensors: Send a signal when submerged in water, lava, honey, or any liquid depending on the liquid sensor used.

Gem Locks: Send a signal when the correct Large Gem is placed or removed from the lock.


A special case here is Timers. A signal can toggle their state, and they can send a signal every X seconds if enabled, depending on the timer used. Timers can't toggle themselves, but can trigger something that will, like a logic gate.

Devices:

Teleporter: The Teleporter is a travel mechanism. When two Teleporters are wired together with a triggering mechanism, they can exchange players, NPCs, and most enemies between them. Teleporting is always instantaneous, has no load time or cooldown, no Mana or coin cost, and no limit on distance.

Active and Inactive Stone Blocks:


Active Stone Blocks and Inactive Stone Blocks are blocks that act as mechanisms. These unique stone blocks behave as a single block whose actuation can be switched "on" or "off" using wires instead of the traditional Actuator. These blocks share two unique numerical IDs for each of their on and off states and are used in world generation for traps.
Logic Gate Lamps
Logic gate Lamps are placed on top of Logic Gates, representing the on & off "inputs", to determine if a Logic Gate is activated or not, as per their gates logic. For example, an AND gate requires all lamps above the gate to be "on".

An off lamp represents an off signal while an on lamp represents an on signal.



Logic Gate Lamp (Off)
  • Placed on top of logic gates to add checks.
  • The off lamp represents an "off" state or "Input".



Logic Gate Lamp (On)
  • Placed on top of logic gates to add checks.
  • The off lamp represents an "on" state or "Input".



Logic Gate Lamp (Faulty)
  • Place this on logic gate lamps to randomize the activation of the gate.
    (More on this in a later section.)
Logic Gates (AND, NAND, OR, NOR, XOR, XNOR, NOT)
Now, we'll talk about Logic Gates.
It consists of Logic Gate blocks and Logic Gate Lamps.

A logic gate sends a signal when switching its state. The state of logic gate depends on the logic gate lamps above it. There are 6 different logic gates: AND, NAND, OR, NOR, XOR, NXOR. These are analogous to real world logic gates.



AND GATE
  • Turns on when all lamps are active.
  • An AND gate is used to detect whether all inputs, or lamps, are turned on. The output is toggled to "on" only when all lamps are "on". Otherwise, the output will remain "off".







  • Another version of the AND Gate is the Faulty AND gate. This version uses a faulty lamp on the top instead of an off lamp. This behavior causes the gate to have a neutral mode that is neither on nor off. This is very useful as faulty gates can be stacked on top of each other and act as separators, which helps to avoid crossing wire colors.




NAND GATE
  • Turns on unless all lamps are active.
  • The NAND gate turns the output off only when all inputs are on, the reverse of an AND gate.







OR GATE
  • Turns on when at least one lamp is active.
  • An OR gate is used to detect if any of the inputs are turned on. The only time the output is "off" is when all inputs are "off".






NOR GATE
  • Turns on when no lamp is active.
  • An NOR gate is the opposite of an OR gate. Whenever at least one switch is toggled to "on", the output is toggled to "off". The only time the output is "on" is when all inputs are toggled to "off".






XOR GATE
  • Turns on when exactly one lamp is active.
  • An XOR gate is a gate that turns on specifically when only one input is turned on.








XNOR GATE
  • Turns on when the total active lamps is not one.
  • An XNOR gate will only turn on when the total switches on are not one, the opposite of an XOR.








NOT GATE
  • Inverts the input signal.
  • A NOT gate, also known as an inverter, gives you an output which is the opposite from the input. For instance, when the input, is set to "on", the output will be toggled to "off".
  • NOT gates are not in the game as, under normal conditions, they would simply emit a signal every time an input changes; However, for more advanced circuits, NOT gates are often referred too as "buffers" and are essential for logical delays.












SHORTED GATE - DUAL ACTIVATION
  • While not a cannon logic gate, this technology in Terraria allows for a single signal to be activated twice. This, under normal conditions, would be considered a short-circuit (Indicated by the smoke), but for certain applications this can be very useful.
Flip-Flops (SR, T, D)
Flip-Flops are essential components in circuitry that store and control binary states (on or off). They are particularly useful for a variety of applications due to their ability to retain a state until an input changes it. This makes them fundamental for both basic and advanced engineering.



Toggle flip-flop (T flip-flop)
  • A toggle flip-flop is a device with one input and changes state every other input.
  • Daisy-chaining T flip-flops together can be used for binary counters or longer input delays.










Set/Reset flip-flop (SR flip-flop)
  • Allows the first input to pass and change the state, while multiple activations after that, on the same input, will not change the state. Using the second input will then change the state.
  • Useful for single-activation switches and doors.






Data flip-flop (D flip-flop)
  • Captures and holds the value of the data input.
  • Used for storing binary data and synchronizing signals.
Latches (JK, RS)
Types of sequential logic circuits are not too relevant to this game due to how the wiring mechanics exist. In real-life digital circuits, inputs can be active high or active low. For example, in active high circuits:
  • For an SR latch: An input of 1 for "S" (set) means that the output Q is set to 1, and an input of 1 for "R" (reset) means that Q is set to 0.
  • For active low circuits: An input of 0 for "S" means that the output Q is set to 1, and an input of 0 for "R" means that Q is set to 0.
However, in Terraria, wiring is pulse-based rather than state-based, which means these nuances in input types and states are less relevant.

Detailed Explanation:
RS Latch (SR Latch): This is essentially an SR latch designed to handle the condition where both inputs are active at the same time. In a typical SR latch:
  • When S = 1 and R = 0, the latch is set (Q = 1).
  • When S = 0 and R = 1, the latch is reset (Q = 0).
  • When S = 0 and R = 0, the latch holds its previous state.
  • When S = 1 and R = 1, the latch enters an invalid state, which is avoided in practical applications.

(This is a RS flip-flop circuit made according to the digital circuits book. However, most people won't be using it when making circuits in Terraria. We have much simpler and easier edge-triggered D flip-flops and edge-triggered T flip-flops.)


JK Flip-Flop: This is a more advanced flip-flop that addresses some limitations of the SR latch. It has two inputs, J and K, and a clock signal:
  • The JK flip-flop changes its output state based on the clock signal.
  • When J = 1 and K = 0, the flip-flop is set (Q = 1).
  • When J = 0 and K = 1, the flip-flop is reset (Q = 0).
  • When J = 1 and K = 1, the flip-flop toggles its output state.
  • When J = 0 and K = 0, the flip-flop holds its previous state.


Conclusion:
The main difference between SR and JK flip-flops is how they handle the case when both inputs are active at the same time. The JK flip-flop can toggle the output state, whereas the SR latch enters an invalid state if both inputs are high.
The MechScope Mod
The MechScope Mod

It's important to mention this mods existence before moving on. There is one big issue with wiring: you can’t really see what is actually going on. Everything happens instantly once you flip the switch. This isn’t a big deal if you just want to build simple door mechanisms or traps, but when you have a huge chain of logic gates, things quickly become confusing. To resolve this problem, DRKV333 created MechScope, a TModLoader mod, that can pause and visualize the wiring execution process.

While this mod is NOT required for building circuits, it will really help when things start to get complex. Feel free to read more about how it works and its features on it's official download page on steam. tModLoader - MechScope.




Flat Wire Texture Pack

Due to a high demand for this resource pack, I decided to add it to this guide. This texture pack simply changes the textures of wires to a more flat style. This is very helpful in the design of complex wiring circuits, and personally, I prefer these wire appearances much more.

The wire texture's in this pack where originally conceptualized by yfdyzjt and later illustrated by crypticnight. Feel free to subscribe to the workshop item and give it a try: Flat Wires.

(click the illustration to enlarge)
Simple Logic Devices
In this section, I will be going over the very basics of different logic devices and how they operate. This will give you a fundamental understanding for when we further break down these components in each section. Just know, you can combine these devices in different ways to create all sorts of mechanisms. This section will be in "logical" order, first walking you through the most basic concepts, and then building up more complicated setups.

For this section, huge credits go out to DRKV[forums.terraria.org] for allowing us to use some of his existing examples on his original post A reference guide for simple logic devices[forums.terraria.org].

As a side note: All of the gates I used here are AND gates. In Terraria, you don't really need the other logic gates aside from AND and XOR.


Signal Manipulation

Diodes:

Single lamp diodes are often used for purposes such as:
  • Transferring a signal to a different wire color
  • "Delaying" a signal by one logic gate execution step to change the order in which other gates get triggered
  • Controlling the direction of signals
  • Limiting the number of signals that pass through (more on this later)



Timer Delay:

This setup lets you delay a signal by up to 5 seconds. You generally can’t make a timer just turn itself off, so here we trigger a logic gate, which in turn will switch the timer off.

To create longer delays you can create a timer cascade or use some form of counter. We will be covering this topic in one of the next sections.



Timer Cascade Example:



The Doubler (aka Dual Activation):

What is smoke?
Logic gates will only trigger once per wiring iteration. If their output value is changed again, they will just emit a puff of smoke and nothing else will happen. This is to prevent freezing the game with an infinite loop by hooking a wire up to one of its inputs. A deeper explanation is on this post[forums.terraria.org] by Niranufoti.

However, this can be abused to make all sorts of logic possible. Here, we use them to immediately generate a second signal if the red wire gets triggered. Two consecutive signals like can be very useful to get other logic gates to do what you want them to.




Limiting Signals:

Running a doubled signal (or pretty much any number of signals) through a diode will only let the first one through, turning it back into a single signal.




The Tripler:

You can combine signals from different logic gates to get more triggers. This setup will triple the input.




Transistors

In Terraria’s signal based wiring, Boolean (on or off) AND gates are not necessarily very useful. What we really want, is the ability to kind of “gate” a signal. Let it through at certain times and stop it at others. You can’t achieve this with just a simple AND gate. For instance, if your “gate” and your “trigger” lamps are both ON, switching the gate OFF will create an output, which we don’t want.



Faulty Transistor:

Faulty gates, when their faulty lamp is triggered, will generate a signal with a probability determined by the ratio of ON gates to OFF gates. If the lamp here is ON, we get an output with a 1/1 chance, when it’s OFF we get it with a 0/1 chance. This effectively acts as a transistor. The state of the lamp (the base) determines whether the signal can pass from the faulty lamp (the collector) to the gate’s output (the emitter).





Smoky Transistor:

There is another way to create transistors. The problem with using just AND gates is that the state of the collector lamp will affect its behavior. When the lamp is OFF things are fine, but once you turn it ON, toggling the base can cause problems. So let’s just keep the collector OFF. By doubling the input signal before sending it to the collector, we immediately switch the collector lamp OFF after it turns ON. We don’t get a second output signal by doing this, because the two triggers both happened in the same iteration. The second one will only emit a puff of smoke.




The big advantage of smoky gates, is that you can add multiple lamps to it, to AND them together. With faulty transistors you need to add an additional AND gate for that.

Simple Circuits
Below is a collection of a few useful wiring circuits you may find yourself building in some of your own wiring builds!

Simple Devices

Reset Switch:

This device can be used to reset a toggleable device to a certain state. Once the transistor is triggered, it will turn its own lamp OFF and whatever is attached to it as well.




Reset switches can be easily stacked next to each other to create compact designs.




Inline Reset Switch:

This is a different reset switch that relies on smoky logic instead of faulty gates. Their big advantage, is that you can run a wire straight across them vertically. This allows this setup to have the switches above the gates instead of having them on the bottom.




Binary Counter

Just like the name suggests, these devices will gradually increment a number in base two. This can be useful if you want to wait until something, like a timer for instance, has triggered some number of times. Just remember, we will be going more into depth on this in a separate section.

Divide by Two:

The main idea behind these, is to make a gate, that will only output once for every second signal it receives.




The Counter:

Once you can divide a signal by two, you can also divide it by 4, 8, 16 and so on. You can just chain these dividers together, to translate the number of pulses the devices received, into a binary number.




Shift-R Based Counters

Quite often you want to send a signal from a wire to different devices, one after the other. You can use this to do all sorts of things, like to make scrolling light displays, wait for some number of inputs, or to “move” a light or selection left or right.

The Shift Register:

All you need to do, is link up a bunch of self-resetting transistors to each other’s enable lamps, and common the triggers together.




You’ll notice, that the lights hooked up to the output of the device don’t really seem to “shift”. (It kind of looks like the output of a Johnson counter.) That is because we are only sending one signal to each of them. We also want to turn them OFF, once the next output is triggered. So all we have to do, is hook up the output of two consecutive segments to each torch.
You can also connect the end of the counter to the beginning to create a circular counter.




If you want to connect this up to something more complicated, you should switch the torches for some diodes, and then you only have to run one wire per stage to your output.


Sequencer:

If you hook up different inputs to all of the segments on the shift register, you can use it to check if something happened in a certain order. You can use this to make simple password lock mechanisms.




Single Selector:

Like the Sequencer, this design only allows a single input to output to be selected at one time.


(designed by yfdyzjt)


Compact Resettable Counter:

You can move the segment of the counter closer, but then you need to use three different wire colors. This also makes wiring anything useful to it quite difficult, but you can still use it for a timer. We can however easily connect a reset array to it, thanks to the inline reset switch.




One Way Teleporter:

By hammering teleporters flat, they can act as a one way teleporter.

(designed by Cryptic)


Conclusion

With the circuits and devices covered in this section as well as the topics covered later on, you will have a solid foundation to build more complex and interesting wiring setups. Whether you're designing intricate reset switches, creating dynamic shift registers, or implementing binary counters, these components can be combined in countless ways to achieve your goals. The possibilities are vast, so experiment, iterate, and innovate as you integrate these designs into your builds!
Timers / Engines (Clocks) / Delay Circuits
As we all know in making traps, farms, or even the simplest of contraptions, adding some type of timed event or a delay to it is very important! Same goes with complex circuits; they too may need a basic or more precise type of clock. So in this section, we will be going over all the various types of clocks used in Terraria.

What Are Clocks?

Clocks in Terraria are devices that create a repeating signal. These signals are critical for automating processes like traps, farms, and other contraptions. A clock is often used to repeatedly activate a mechanism, whether it’s firing a dart trap, spawning mobs in a farm, or cycling through a sequence of events. By controlling the timing of these signals, you can create everything from simple pulsing mechanisms to complex, programmable systems.

What is Hertz (Hz)?

In Terraria, especially when working with complex circuits, the term "Clock speed", "Frequency", or "Hz" are used interchangeably to describe how fast a circuit is.

Frequency is the rate at which current changes direction per second. In games like Terraria or Minecraft for example, it describes how fast a single operation is completed at a given clock speed, aka: "hertz".



Hertz (Hz) is an international unit of measurement where 1 hertz is equal to 1 cycle per second. So for example, a 5-second timer is equal to 0.2Hz. (1 / 5 = 0.2 Hz)

Types of Clocks (Engines)

1) Timer's
Within the base game, there are five different types of timers.
  • 1/4 Second Timer (4 Hz)

  • 1/2 Second Timer (2 Hz)

  • 1 Second Timer (1 Hz)

  • 3 Second Timer (.33 Hz)

  • 5 Second Timer (.2 Hz)
Example:


Sequential Timers:
Sequential Timers can be achieved by daisy-chaining multiple timers together resulting in a much longer delay. This method also allows you to mix different timers together. The following design uses dual activation to stop the final timer.



(designed by yfdyzjt)

2) Target Dummy Engine
By far the most widely used, Target Dummy engines are very consistent and stable clocks that can be adjusted to nearly any Hz.

Before talking about how these clocks work, it's important we talk about how Target Dummies work in Terraria. The normal intentions are to test your weapons damage as shown bellow.


However, what not many people know about, is when you place a target dummy, it actually spawns an invisible and also invincible entity that sits at the base of the stand. We call this entity a "ghost dummy". These ghost dummies can actually fall with gravity, be hoik'ed, be teleported, and also set off pressure plates. The only draw back in Target Dummy engines, is pre-existing target dummies, once loading back into a world, do not spawn a ghost dummy unless the player is within 100 tiles.

How Target Dummy Engines Work: Target Dummy engines work by Hoik'ing the ghost dummy back and forth between two Hoik's with pressure plates resting on top of them. They use the simple method of teleporting the ghost dummy into the hoik chamber.

One pressure plate; 30 Hz. Two pressure plates; 60 Hz.


Visual example of what is happening to the target dummy:


Stacking Target Dummies: Another property of the ghost dummy is the ability to stack multiple target dummies on top of each other and have their ghost fall onto the teleporter. This causes the speed to double. Using the well known teleporter glitch, it's possible to have target dummies or any placeable object to float in Vanilla without editors.

Steps:
  • Stack two teleporters on top of each other.
  • Place a target dummy on top of the two teleporters.
  • Break the bottom teleporter.
This causes your target dummies to float. Notice how the ghost fall down with gravity.




Each target dummy added to the Engine adds 60Hz as long as there is two pressure plates. You can use the following formula to calculate the frequency given x target dummies.
(30 Base-Frequency * Total Target Dummies) * TotalPressurePlates = Output Hz



3) Portal Gun Station Engine
Portal Gun Station's have a maximum range of 673 blocks and have a rate of fire of 120 shots per minute. So making a clock with them causes the surface area to be very large. These types of clocks have a maximum frequency of 348 Hz. The huge advantage to these types of clocks is that they do not require a player to be near it to load them and it's fairly easy to adjust the frequency from 1-348 Hz by simply adding or removing teal pressure plates.

Example:


4) Bird Engine (Obsolete)
Bird engines were a popular engine used back in 1.2 when modern game mechanics, such as target dummies, did not exist. They were used to generate frequencies greater then the 1 second Timer. They use the AI of the bird that moves back and forth between pressure plates.

Example (12 Hz):


5) Crab Engine (Obsolete)
Similar to bird engines, the crab engines were a popular engine used back in 1.2 when when modern game mechanics, such as target dummies, did not exist. They were used to generate frequencies greater then the 1 second Timer. They use the AI of the crab that, when trying to path-find up a block, would cause it to constantly jump up and down. This has since been patched. You can see a working example in this video by Yrimir. You can find more visuals on these obsolete Engines via this video by Ry P.

Example (~6 Hz):



Adjustable Delay Circuits
When making complex timing circuits, it's necessary to fine-tune the circuit to the correct frequency. The most common method of adding delays is by using a T flip-flop. By daisy chaining T flip-flop together, they can be used as input delays.



Each T flip-flop in the chain divides the signal by 50%. For instance if I have a 60Hz clock and I add two T flip-flops in concession, the formula would be 60 Hz / 2 / 2 = 15 Hz.
  • It's important to remember each dummy added, adds 60 Hz.

Viable version via a shift register:

(designed by yfdyzjt)
Wireless Data Transfer
Wireless data transfer is a form of technology where you can send bits (1's & 0's) across long distances without the use of any physical connections. In Terraria, by combining portal stations with teal pressure plates, you can create a system that sends a signal to a remote location. Wireless data transfer consists of three key components.
  • Transmitter: A device responsible for encoding and transmitting the data.
  • Repeater: A device responsible for extending a signal.
  • Receiver: A device responsible for decoding and receiving the data.


How Does It Work?

As covered in an earlier section, teal pressure plates are triggered by projectiles or pets.




This allows the beams of portal gun states to also be detected by teal pressure plates as the beams are projectiles.




The unique thing about Portal Gun Station's is they have a maximum range of 673 blocks and have a rate of fire of 120 shots per minute. This makes them very effective at moving data physically at crazy speeds. Bellow is an illustration of portal guns sending 1 byte (8 bits) worth of data.



As mentioned above, Portal Gun Station's is they have a maximum range of 673 blocks. This means for sending data over longer distances, we will need to use a "repeater". A repeater will take a signal at the 673 threshold and send out a fresh signal with it's range reset.



With this technology we can send any desired types of information wirelessly across long distances. Bellow is an example created by Paul that visualizes this technology.

The portal gun stations sending data:


A matrix display and keypad for selecting the data:


Wiring showing separation of circuits:
(designed by paul)

Wireless Data Transfer Conclusion:
In conclusion, it's a very useful technology for sending data over a very long space without physical connections. While this technology is very impractical, it's a good demonstration of how real world circuits work.

Below is a great video that showcases one of the first documentations of this concept.
Randomizers
Placing a faulty logic gate lamp above a logic gate turns it blue, overriding its normal functionality and changing its behavior entirely. The logic gates function as a randomizer instead, and can no longer turn on or off. The gate no longer emits signals when normal logic lamps above it change state. Instead, when the faulty lamp is triggered by a signal, it randomly selects one of the logic lamps below it. If that lamp is on, the logic gate emits a signal.



So, if there are three lamps below the faulty lamp, two ON and one OFF, the gate has a 2/3 chance to emit a signal when the faulty lamp is triggered.

Results from four separate tries:


Calculating Randomization

You can use the formula below to create a specific randomizer ranging from chances 0% - 100%.
  • Example: 1 / 4 = (0.25 * 100) = 25%.
Turned ON Lamps / Total Lamps = Chance

Full Reference Chart:
Chance %
On/Total Lamps
0%
0/1
1%
1/100
2%
1/50
3%
3/100
4%
1/25
5%
1/20
6%
3/50
7%
7/100
8%
2/25
9%
9/100
10%
1/10
11%
11/100
12%
3/25
13%
13/100
14%
7/50
15%
3/20
16%
4/25
17%
17/100
18%
9/50
19%
19/100
20%
1/5
21%
21/100
22%
11/50
23%
23/100
24%
6/25
25%
1/4
26%
13/50
27%
27/100
28%
7/25
29%
29/100
30%
3/10
31%
31/100
32%
8/25
33%
1/3
Chance %
On/Total Lamps
34%
17/50
35%
7/20
36%
9/25
37%
37/100
38%
19/50
39%
39/100
40%
2/5
41%
41/100
42%
21/50
43%
43/100
44%
11/25
45%
9/20
46%
23/50
47%
47/100
48%
12/25
49%
49/100
50%
1/2
51%
51/100
52%
13/25
53%
53/100
54%
27/50
55%
11/20
56%
14/25
57%
57/100
58%
29/50
59%
59/100
60%
3/5
61%
61/100
62%
31/50
63%
5/8
64%
16/25
65%
13/20
66%
33/50
67%
2/3
Chance %
On/Total Lamps
68%
17/25
69%
69/100
70%
7/10
71%
71/100
72%
18/25
73%
73/100
74%
37/50
75%
3/4
76%
19/25
77%
77/100
78%
39/50
79%
79/100
80%
4/5
81%
81/100
82%
41/50
83%
5/6
84%
21/25
85%
17/20
86%
43/50
87%
87/100
88%
22/25
89%
89/100
90%
9/10
91%
91/100
92%
23/25
93%
14/15
94%
47/50
95%
19/20
96%
24/25
97%
97/100
98%
49/50
99%
99/100
100%
1/1
-
-

Example Circuits

Random Output:
  • Each activation emits a random output.

(original design by yfdyzjt, redesigned by ekinator)


(designed by DRKV)

Random Output W/H Single Selector:
  • Each activation emits a random single signal.

(designed by yfdyzjt)

6-Bit Fill:
  • Each activation emits a signal to each of the 6 outputs in a random order.

(designed by ekinator)
Randomizers - Continued
Zero Chance Randomiser - By ekinator


The Zero Chance Randomiser created by ekinator is a useless machine who's probability is height^width making it the most dense possible randomizer within Terraria. The one illustrated below has a one in over two trillion chance of emitting a signal.



Being this randomizer has such a high probability, I have created two projects for helping in both calculating and visualizing their probabilities.


This randomizer can also be seen used in this map where the chance of winning this mini-game is 1 in 4 nonillisexagintaquadringentillion. The odds of winning the jackpot in the US lottery is 1 in 300 million. You would have a higher chance to win 3352 consecutive lotteries before winning a single game.

(A single nonillisexagintaquadringentillion has 28380 zeros behind it)
Multiplexers (MUX - Binary Decoders)
A "MUX", or Multiplexer, is simply a binary decoder. A MUX converts a binary input into a decimal output. Multiplexers have a very wide range of uses from scoreboards, RAM / ROMs, to even displays.

It's important to understand, while the term "MUX" is being thrown around fairly loosely in this guide, I want to make sure you understand the proper terminology and their functions.

Encoder:
  • An encoder converts multiple input lines into a smaller number of output lines by assigning a unique binary code to each input.
Decoder:
  • A decoder does the opposite of an encoder. It takes a binary code as input and activates the corresponding output line.
Multiplexer (MUX):
  • A multiplexer selects one of several input signals and forwards the selected input to a single output line.
Demultiplexer (DEMUX):
  • A demultiplexer does the opposite of a multiplexer. It takes a single input signal and routes it to one of several output lines based on selector inputs.

(visual by Haku)

How It Works
Binary data in its self is comprised of 1's & 0's but is essentially just encoded whole numbers. We use binary as it takes these whole numbers and breaks them down into a language easier to comprehend with logic gates. As a by-product of this, it also creates a form of "compression".

Lets use an example: Say we have 4 unique binary inputs. This 4 long binary number actually has 16 unique outputs. This works because the 4 input "bits" (1's & 0's) can be rearranged in 16 different unique ways. So we use a multiplexer to automatically sort out these combinations from our binary.


As you can see in the illustration, there are 16 logic gates with a stack of 4 lamps on each. The lamps, if you look closely, are all arranged in a unique pattern. Not a single logic gate contains the same pattern. This in-turn, allows us to lay wires horizontally across the lamps and change the logic gate that gets activated, with two logic gates never being activated at the same time.


Demonstration:


In binary, each additional wire adds a output value of 2^N, where N equals the additional bits or "wire". Below is a chart showcasing the maximum unique combinations achievable with each additional stack height aka "bits". When building a Multiplexer, it's important to understand how large you will need to build it. This is determined by the size of the max binary signal you will be sending through it.
Stack Height (Bits)
MAX VALUE
1
2
2
4
3
8
4
16
5
32
6
64
7
128
8
256
9
512
10
1024
11
2048
12
4096
13
8192
exc..
exc..

How They're Built
A MUX is constructed by alternating on and off lamps on-top of each other and increasing the lamp variation incrementally each layer. Below is a simplified example of this.

Step 1:
  • We start by combining two symmetrical 1-bit on / off logic gates together.
  • Being only one wire can lay horizontal, this is equal to 1-bit of binary data.


Step 2:
  • Now we lay the second layer of lamps to make a 2-bit MUX.
  • Notice how we increment the pattern each new layer. Now its on on, off off.


Step 3:
  • Finally we have a completed 2-bit MUX. This can take 2 wires and give us 4 unique outputs.


For making much larger Multiplexers, you can simply copy and paste the MUX next to itself after each layer and place on and off lamps respectively on the top. As stated before, each new bit you add to the MUX is symmetrical and will stack next to itself in adding one additional layer or "bit".


Example using TEdit[github.com] to aid in the creation:


Advanced - Calculating Stack Patterns of X Positions
This is technical information about calculating the stack pattern of a MUX for random positions. While this knowledge is mostly useless, it could be useful to select people.

For this example, I want to find the lamp pattern for decimal value 556.
  • Bellow is an image of what it should look like.


Now using the programmer mode on Windows calculator, we can get the binary value for the decimal value 556. From there, we can run some simple conversions to binary as shown below.

Decimal Value:
556

Binary Value:
001000101100

Inverse Value:
110111010011

Reverse Value (To flip the mux upright):
110010111011

Trim To Max Value (556 fits in 1024 = 10):
1100101110

And as we can see, we got 1100101110 as our final value. The 1's represent on lamps and the 0's represent off lamps. And if we put this together, you can see below the correct result bellow. For automating this process, here is a dotnetfiddle[dotnetfiddle.net] with the example 556. Feel free to change this value to whatever desired value you may need and simply press run.



Conclusion
When making technical circuits, especially ones that deal with data or transferring of data, it's important to know how to convert that data into something that can be displayed, like on a scoreboard or in whatever decimal value you need. It's important to note, there are many other types of Multiplexers that can be created. Anything that takes an encrypted input, such as binary, and converts it to plain format, such as decimal, can be considered a Multiplexer (MUX).

Below is a great video that talks about Binary and breaks it down at a very fundamental level.
Binary Counters
A binary counter is a device used for generating or incrementing a binary number. Binary counters are essential for conducting complex operations and for building major circuits. Each output of the binary counter represents a bit in the binary number, and the counter advances its count in a binary sequence (0000, 0001, 0010, etc.).

How Binary Counters Work
Counting: Binary counters count in binary. Each pulse or clock signal increments the counter by one.
  • For example, a 5-bit binary counter can count from 00000 to 11111 (0 to 31 in decimal).



Components:
  • Flip-Flops: Binary counters use flip-flops, which hold one bit of information. Each flip-flop represents a bit in the binary count.
  • The flip-flops are connected in series, with the output of one flip-flop driving the clock of the next.
  • Clock Signal: The clock signal controls when the counter increments. Each pulse of the clock causes the counter to move to the next value in the sequence. For the following example, the switch is the clock.


Use in Terraria Circuits
In Terraria, binary counters are used in circuits both simple and complex to create various mechanisms and automation systems. Below are some of just many uses they can be used for:

Event Timing: They can be used to time events or delays. For example, a counter could control how long a door stays open before closing or how long a light stays on.



Signal Encoding: Binary counters can encode signals for other components. For example, they can generate a sequence of signals to control a series of lights or traps.



Complex Logic Gates: In conjunction with other logic gates and circuits, binary counters can be part of complex logic setups. They help manage the flow of signals and control various parts of a circuit based on the binary count.


(as seen on the left hand side, a bcd display is being used for showing the frame-count)


(as seen on the right hand side, a bcd display is being used for debugging)

Display Systems: They can drive display systems, such as counters or indicators, showing numbers or states based on the counter’s value. This is useful for visual feedback or for creating scoreboards.

Below is a BCD (Binary Coded Decimal) Display displaying binary to decimal from 0-9 to A-F (Hex). For displaying binary larger then 4-bit binary, you will need to use a Binary to Decimal circuit. We will not go too much into that here in this section as its beyond the scope of this topic, but these displays are very helpful for visualizing or debugging large numbers within circuits.



Advanced Counters

Here is a binary counter that has the ability to count backwards. Yes you heard that correctly! When making a counter, sometimes you may want to have it count backwards for various reasons. A good example is for navigating sequential storage such as some ROM's or RAM's.

(designed by Cubs)

Here is another binary counter design that also has a clear option. This allows you to reset back to 00000 from any forward or backward position. Very useful for quick navigation.

(designed by Cubs)

Below is an extremely compact binary counter with +1 forward, -1 backward, and a reset.
(designed by Haku)

This final design is a second version remake of the one above. This version allows you to manually select the starting point of the counter. Great for quick navigation to and from.

(original design by Haku, re-designed by Yfdyzjt)

This is a normal binary counter with a logical right shift. This is useful for select applications where you need to move data to another cell or shift it for adding new information. This was added as an introduction into our next topic: Shift Registers.


(designed by NanoPi)

Conclusion
The versatility of binary counters in Terraria circuits comes from their ability to count and trigger events based on a predictable sequence, making them useful for creating complex and dynamic systems.
Shift Registers
What is a Shift Register?

Shift registers are a type of digital circuit used to store and shift data. In digital electronics, a shift register is a series of flip-flops connected in such a way that data can be shifted in or out of the register one bit at a time. Shift registers can be used to store data, shift data left or right, and move data between different parts of a circuit.



Below is an example of a horizontal shifter with reset. These circuits are useful for scoreboards.


Building a Basic Shift Register
  • Create a Memory Cell: Use a flip-flop circuit (commonly a T-flip-flop or RS-NOR latch) to store a single bit of information.

  • Chain Memory Cells: Connect multiple memory cells in a chain. Each cell will represent a bit in the shift register.

  • Add Control Signals: Use wires to create control signals that will shift data from one memory cell to the next.

  • Testing and Use: Test your shift register by sending input signals and observing the output. Adjust the connections to ensure it behaves as expected.


Example Uses

Data Storage and Manipulation: Shift registers can store and move data, such as signals for controlling devices.

(designed by cubs)

Binary Counters: You can create a binary counter using a series of flip-flops, and with some additional logic, you can shift this data left or right. This is useful for timers or scoreboards.


(designed by NanoPi)

7-Segment Displays: By using a shift register to control which segments of a display are lit, you can create numerical displays.
(original design by TheRedstoneCrafter)

Scrolling Displays: As shown in the beginning of this section, Shift registers can control displays (like binary counters or scrolling signs) or handle input from buttons and levers by converting serial input into parallel output. This design uses state serial to loop the shifter back to the beginning. We will be talking more about serial in a later section.

(designed by yfdyzjt)

Clocked Circuits: When using clocks (repeating signals) to create a timed sequence of operations, shift registers can be used in conjunction to create complex timing and sequencing mechanisms. A good example of this is the 12-hour clock illustration shown bellow.

(designed by r4v1n6)

Sequential Logic: For example, when it comes to a clock circuit or a memory system, Shift registers help move data through the system in a controlled manner. You can use memory cells to store binary data. A series of these cells can act like a shift register to keep track of complex information or states. Below is an example of a Shift register being used to turn this RAM into sequential storage. We will be talking more about digital storage types later in this guide.


Conclusion

Shift registers in Terraria, while abstracted from their real-world counterparts, offer a powerful way to manipulate data and create complex circuits. Shift Registers can be designed for any application, regardless of the vertical and horizontal obstetrical.

Horizontal Shifter W/H Looping:


(designed by cubs)

Left + Right Shifter W/H No Looping:


(designed by yfdyzjt)

Left + Right + Reset Shifter W/H No Looping:



Vertical Shifter W/H Looping:

(designed by cubs)
Decimal Counters / Scoreboards
In this section we will be going over scoreboards and counters. These devices are essential when making adventure maps, mini-games, or other similar circuits.



Above is a single digit counter based on a design by TheRedstoneCrafter. It works by using a shift register and a decoder. As we already went over, a shift register is a type of digital circuit used to store and shift data.



Decoders - What Are They & How They Work

Now it's time to talk about decoders. Similar to a MUX (Multiplexer), decoders take a binary input and encode it in a way that can be interpreted by a display or other digital components.

Binary decoders takes a binary input and activates a specific output based on that input. For example, if you have a 3-bit binary decoder, it can handle 8 different binary inputs (000 to 111), and each input corresponds to a unique output. Decoders, under unique circumstances, can sometimes be classified as ROMs (read only memory), as they can be programmed with unique patterns and when combined with a binary shifter, can output a desired set of data, such as decimal.

Below is a simple visual example of what many people know binary decoders to look like in the game Minecraft.

(2012 Image by user Storm_Inc[www.planetminecraft.com])

Following that same format in Terraria, we get the following example. As you can see, each switch (input) is connected to a unique pattern of lamps below. This in-turn causes each switch to have a unique defined pattern of outputs when toggled. Using this method, we can essentially "program" what segments of a numerical display is lit per input.

(illustrated original concept by cubs)

Applying this knowledge, we can make a decoder that takes a single decimal input, and converts it to a unique 7 segment pattern that makes up a number, as mentioned above. We call this a Decimal-to-BCD Conversion. More on this is in a later section.


Encoders - What Are They & How They Work

It's important to cover encoders as they're a vital function to specific circuits. An encoder is a device or setup used in circuits to convert and interpret signals, often for encoding or decoding information. They play a crucial role in various mechanisms and contraptions. Below is a simple example of that in action.



As you can see, each switch is using a unique corresponding color. This creates 15 possible color combinations or a 4-bit binary encoding that can be decoded back into decimal using a decoder.



Scoreboards

Now that we know the basics of how counters work, we can throw a few of them in a series; this creates a multi-digit counter or scoreboard. The way these work is when one shift register reaches the last bit and shifts back to zero, it also sends a signal out to another shift register and increments it by a single tick. This in turn, allows you to daisy-chain as many counters as you want together and it creates decimal value of your choosing.

Below is a compacted decimal counter created by 白霜心, yfdyzjt, putianyi888, and possibly others.
BCD Displays (7 Segment Decoders)
In a Binary Coded Decimal (BCD) encoding scheme, each of the decimal numbers (0-9) is represented by its equivalent binary pattern (which is generally 4-bits).

A Seven segment display is an electronic device which consists of seven Light Emitting Diodes (LEDs), or in Terraria's case, Torches or Pixelboxes, arranged in a some definite pattern, which is used to display Hexadecimal numerals (in this case decimal numbers, as input is in BCD i.e., 0-9). It's important to note, 4-bit is 16 decimals. So decimals 10-16 (9-15) can be represented in A, B, C, D, E, F for HEX.



Compact BCD 7-Segment Display (0-9)

Decided to post this before someone else tries to claim they invented it. During research for the Transmute Workshop[forums.terraria.org] (workshop link) project, we designed a compact pixel-box display with the help of ekinator, putianyi888, and yfdyzjt.

So a while back, putianyi888 designed the famous BCD Digital Display[www.bilibili.com] shown below. This was designed using a python math algorithm script to generate the smallest possible combination of wires and logic gates. You can read more on his GitHub[github.com].



Compact Pixelbox BCD 7-Segment HEX Display (0-9, A-F)

This brings us to the pixelboxes. Pixelboxes in 1.4.4 had their logic changed. Thanks to some conversations with Leinfors and I, they now support infinite display resolutions rather than the previous max being 24-Horizontal.



For the Transmute Workshop[forums.terraria.org] (workshop link) project, I really wanted to push the engineering technology to the highest bar possible. In doing so, we created two versions. The first one was first introduced and worked to final production by ekinator. Taking influence and with help from putianyi888, he created another script and a bunch of math to generate the best combination of logic gates to compact the pixelboxes to a BCD Digital Display. You can find his math here on his github page called TerraBool[filipssh.github.io]. Take a look at all his math equations here on this Imgur[imgur.com]! Some time later, ekinator had developed a true 0-9, A-F, display that utilized the full potential of the four bit binary input version using this hand written Truth Table[i.imgur.com] and his GitHub[github.com]. Following this, putianyi888 once again compacted this further with his design.



Soon after this discovery and achievement, we needed to convert this into something that could be used for a tillable screen in Transmute Workshop[forums.terraria.org] (workshop link) project. A few designs were pitched, but it was ultimately yfdyzjt that came into the picture and created a truly magnificent piece of art. This design allows us to truly create infinitely tillable pixel box displays, similar to putianyi888's torch design. The original design was later reformed to utilize putianyi888's hex design.



Bonus Segments:

XOR 7-Segment:

Below is a bonus 7-Segement display designed around XOR logic gates.

(designed by Mr Giraffe)

XOR 14 & 16-Segments:



There are actually also 14 and 16 segments that exist within real world applications. For very select applications, they can have a purpose within Terraria as well. However, now with the Pixel Box changes in 1.4.4+, matrix displays have long made these obsolete. But for fun, below are two designs created by ZeroGravitas. More info on his post here[forums.terraria.org].

14-Segment Design:


16-Segment Design:
Binary To BCD | BCD To Binary
Understanding Binary to BCD Conversion

As mentioned in the previous section over numerical displays, it's important to be able to display numbers from binary and in some cases, you may want to convert that data back to binary.

When dealing with numerical displays, converting binary numbers to Binary Coded Decimal (BCD) is essential, especially when binary numbers exceed 4-bits. BCD displays allow conversion of binary values to decimal numbers, regardless of the numerical size, making them easier to read. In this section we will learn how they're made and explore how this conversion works.



What is Binary Coded Decimal (BCD)?

Binary Coded Decimal (BCD) converts each decimal digit into its 4-bit binary equivalent. This makes it straightforward to display decimal numbers using binary code. For instance, in BCD, each decimal digit (0-9) is represented by a unique 4-bit binary code:

Binary
Decimal
BCD
0000 0000
0
0000 0000
0000 0001
1
0000 0001
0000 0010
2
0000 0010
0000 0011
3
0000 0011
0000 0100
4
0000 0100
0000 0101
5
0000 0101
0000 0110
6
0000 0110
0000 0111
7
0000 0111
0000 1000
8
0000 1000
0000 1001
9
0000 1001

So for example, if we wanted to convert 357 into BCD, it would be "0011 0101 0111". The way we converted this is we simply take each character of the value 357 and convert them individually to binary.
  • 3 = 0011
  • 5 = 0101
  • 7 = 0111
Once we converted it, we simply combine the numbers. "0011 0101 0111".

How Is BCD Used?

Now that we understand how BCD is converted, what applications does it have? A good example of its usage is in the form of 7-segment displays. These convert a 4-bit binary (4 unique combinations) into a numerical display via a decoder.

As mentioned in the beginning of this section, when a binary number is larger then 9, it will cause the display to go out of range. So BCD is simply converting the binary number into separate binary numbers which are each 4-bits.
  • 357 = 0001 0110 0101 (binary)
  • 357 = 0011 0101 0111 (bcd)


As shown in the illustration above, the three separate displays each use 4-bit binary. If we simply used the raw binary (357 = 0001 0110 0101), the display would show 165. In many cases however, the binary would more then likely be out of range as 7-segment displays cannot display 10,11,12,13,14,15. More advanced displays can actually represent these values in hex, A, B, C, D, E, F, but that's beyond the scope of this topic.

Binary To BCD

Due to the complexity and the nature of converting binary to BCD via logic gates, I will leave out the breakdown of how it works. Below is a piece of work from putianyi888[space.bilibili.com] where he designed a circuit to convert from Binary to BCD[www.bilibili.com].




BCD To Binary

The inverse of BCD back to Binary is a straight forward reversal of the process.
  • 357 = 0011 0101 0111 (bcd)
We each of the 4-bit values and convert it back to it's decimal value.
  • 0011 = 3
  • 0101 = 5
  • 0111 = 7
From decimal, it's as simple as converting from base-10 (decimal) to base-2 (binary).

Below is another piece of work from putianyi888[space.bilibili.com] where he designed a circuit to convert from BCD to Binary[www.bilibili.com].




Bonus - HEX (hexadecimal) Mapout Table
Wanted to throw this illustration in here to show what some tables may look like. This one actually includes the remaining 6-bits in a 4-bit binary input and uses a map-out for A,B,C,D,E,F (HEX). (Truth table corrected by ekinator)

Displays / Screens
Displays are mechanisms used to show or visualize information. There are several types of displays you can create, each serving different purposes.



Types of Displays
Within Terraria, there are a few types of displays that be created. Within this guide, we will only be going over the most common types of displays and screens.

1) The D-flip-flop Grid


How It Works:
  • A D flip-flop, or D latch, is a type of digital storage element that can store one bit of data. It is commonly used in digital circuits to build memory elements and data storage. They can also be used to build a simple screen display by creating a grid of flip-flops to represent each pixel.

  • To toggle a desired pixel, you need to activate the row (X) and column (Y) wires together that corresponds to the desired XY position. This will toggle on or off the desired pixel.


Advanced Concepts:

Below is a compacted version created by yfdyzjt that reduces the area to 1x1 in-between the cells. Due to the complexity and nature of this design, I will not be going into detail on it in this guide.



2) Pixelboxes


How It Works:
  • The Pixel Box is a mechanism that acts like a junction box, that when activated, it looks fully illuminated but does not emit light.
  • To turn the Pixel Box on and off, you need to send both a horizontal and vertical signal at the same time. Note: this signal must be from the same source.


Example showing the same source property:


How To Create Displays:
  • Making displays with the Pixel Box as of 1.4+ is fairly straight forward.


Why Pixel Boxes Had A Logic Change

Many people may not remember, but Pixel Boxes actually used to behave much differently. They used to require both a horizontal and vertical signal to turn on but only a horizontal signal to be reset. This might not seem like much of a change but actually caused a huge limitation to 24 max size horizontally and required insane amounts of logic to operate.


(8x8 legacy pixelbox driver by paul[forums.terraria.org])

This is why we managed to get Leinfors to help us get their logic changed. Bless his soul!


Bad Apple Via Pixel Boxes:


3) Announcement Box Displays
(Illustration from Sonic the Hedgehog '91 Playable Map (DEMO)' created by DontaeRiceArt)

How It Works:
  • An Announcement Box Display is a type of display that uses the games chat interpreter to display colored animations. Announcement boxes can be used to display colored chats by using a special format: "[c/hexColor:String]".

    • Here is an example used for an animation:
      [c/00D5FF:████████████████████]
      [c/00D5FF:████████████████████]
      [c/00D5FF:████████████████████]
      [c/00D5FF:████████████████████]

  • If you'd want to save space, another method is to use these characters in place of the "█
    ░▒▓". And here's a list of other to experiment with wiki/Block_Elements[en.wikipedia.org].

  • The following is possible, within a single message, with the following restrictions, using the █ character:

    • You can produce a message no larger, including text taken to produce colors, than 1193 characters.
    • You can have characters be any HEX Code you want.
    • Resulting pixel art can be no wider than 57 pixels.
    • Resulting pixel art can be no higher than 10 pixels.

    With this, you could have a sign display a message that does cover the entire text box, and create a frame by frame animation.
(Illustration from Sonic the Hedgehog '91 Playable Map (DEMO)' created by DontaeRiceArt)
  • Note: with multiple messages, if you could get them to neatly fire off at or roughly at the same time, you can really have as wide an array of colors per pixel as you want, it still just has to fit the 1193 characters. Even if you used all 57 characters and gave each a different color, that would be 684 characters.

4) RGB Displays


How It Works:
  • A RGB Display is like any normal display but is instead capable of full-color via the use of displaying tiny pixels of Red, Green, Blue (RGB) and when zoomed out they blend to make a full colored image. However in Terraria, due to it's mechanics and unofficial support, there is currently no official method of creating RGB displays.
  • With what we have to work with, colored torches, gemsparks, and pixelboxes; with these limited tools, we can still use very technical levels of ingenuity to create colored displays. Below is an attempt at RGB via pixelboxes by yfdyzjt.

  • A common method for creating RGB displays in other games such as Minecraft, is to use signal states, the strength of a wiring signal, along with some texture packs to apply a color to it. Other methods include pistons and block switching. However, since Terraria is a 2D field, we are very limited in our working space.
  • An attempt at a solution to this would be the use of Wire Bulbs. A tricky workaround using Transmutation allows for full RGB displays. More on next section.


Using texture packs, as similarly shown in a video by mattbatwings, you can change the colors of wire bulbs to reflect a solid color.




RAM
Understanding RAM in Digital Circuits

In digital circuits, RAM (Random Access Memory) is a form of temporary data storage that can be accessed quickly and directly by the system. RAM plays a critical role in wiring contraptions such as computers, as a place for storing and reading the information the processor needs.

It's important to understand that RAM requires a lot of space, but it can be written, and the reading speed is fast. While ROM (Read-Only Memory) the area is small, it cannot be written, and the reading speed is slow. Make sure to choose different storage types for different needs.

Types of storage access:
  • Random Access - Can read or write data in any order regardless of its location.

  • Sequential Access - Can only read data in a +1 and -1 order.
    (like cassette tapes, where you have to fast-forward or rewind to a specific point)
Now, what does this have to do with Terraria? By understanding the basics of RAM, you'll be able to create more complex contraptions that can store and retrieve data, opening up possibilities for memory systems, display animations, counters, and even basic computers.



How Does RAM Work?
RAM is organized into a grid of cells, each of which can store a small amount of data (usually a bit, which is a 1 or a 0 in binary). Each cell has an address, like a mailbox, where the system can store or retrieve information. When the system needs to read or write data, it looks up the address and either stores a new value or reads the existing value from that cell.



Breaking It Down:

Breaking it down to a fundamental level reveals just how simple of a concept storage devices are. Most real world and also game re-created RAM storages are designed using the D flip-flop or RS-NOR latch. D flip-flops, as mentioned in the beginning of this guide, capture and hold the value of the data input, in this case a single bit.

What is a single bit?
  • On Lamp = Represents a 1 (In binary)
  • Off Lamp = Represents a 0 (In binary)


The main reason D flip-flops are ideal for RAM is their ability to "latch" onto and hold a value (either a 0 or a 1) until instructed to change. Using this mechanism, we can combine a few of them together to store multiple bits of information. Lets illustrate how this works below.



In the example above, each column or "address" can hold a single bit of data. Let's show an example of how we can add multiple bits of data per address.



In the example above, we simply added two more rows below our existing registers. This allows us to add two more bits for a total of 3 bits per column or "address". This method of adding more bits allows us to create much larger memory cells and therefore, much larger storage.

As you can tell, this will start to require a TON of space to store data larger then multiple bits. This is why, especially for games where space is limited and a concern, many logic circuits that require a ton of data typically use ROM as it is much more dense. We will cover ROM in the next section, but for now, while on the topic of density, it's important to build smart with the space we have. Below is a design equal to the previous illustration shown, that compacts the resisters as dense as they can possibly be in Terraria; 1 bit per 4.5 tiles (due to the separation).

Tillable Cell:


(designed by yfdyzjt)

Addressing: Just like in real RAM, you need a way to select which memory cell you’re interacting with. This can be done using shift registers for sequential storage or via a MUX (binary decoder) for (random access storage) that controls which cell receives the read or write signal.

However, it's important to understand we cannot just slap a MUX (Multiplexer) on top of this and call it a day. There is an important issue we are yet to address, and that is the order of operations. As you can visually see from the illustration below, both outputs are toggled at the same time.



The issue with this when it comes to RAM, is this will cause the desired bits to be "swapped" with the other columns or "addresses". So we will need to add a circuit to the MUX called a differential. When switching to another column (address), we need to first disable the current column (address), then enable the desired column (address). This prevents both bits from being activated at once, thus flipping (XOR'ing) the entire row.

Within the illustration below, notice how the existing light always turns off first, then activates the new value or light.



Finally we can combine these two circuits to complete our Random Access Memory (RAM).


(designed by yfdyzjt)

Just How Big Is Memory?

For some context on memory size, bellow is a simple chart.

Name
Equal To
Size (In Bytes)
Bit
1 Bit
1/8
Nibble
4 Bits
1/2 (rare)
Byte
8 Bits
1
Kilobyte
1024 Bytes
1024
Megabyte
1,024 Kilobytes
1,048,576
Gigabyte
1,024 Megabytes
1,073,741,824
Terabyte
1,024 Gigabytes
1,099,511,627,776
Petabyte
1,024 Terabytes
1,125,899,906,842,624
Exabyte
1,024 Petabytes
1,152,921,504,606,846,976
Zettabyte
1,024 Exabytes
1,180,591,620,717,411,303,424
Yottabyte
1,024 Zettabytes
1,208,925,819,614,629,174,706,176
ROM
Understanding ROM in Digital Circuits

In digital circuits, ROM (Read-Only Memory) is a type of memory that stores data permanently. Unlike RAM, which is designed to be temporary, ROM is often used to store essential information that circuits like computers need to function. ROM is great for storing preset data or instructions that won't change over time, making it perfect for things like pre-programmed sequences, display animations, map layouts, predefined outputs, and even basic computers.

One of the huge advantages of ROM, is unlike RAM (Random Access Memory), it's very very compact and can actually store 4-bits of data in a single 1x1 tile. While the ROM area is small, it's important to understand it cannot be written, the reading speed is slow, and is also very complicated to program. So make sure to choose different storage types for different needs.

(Terraria But Its Animated Shrek)

How Does ROM Work?
In digital circuits, ROM is typically implemented as a grid of memory cells, just like RAM. However, while RAM cells can be both read from and written to, ROM cells are "programmed" with a fixed value (1 or 0) during manufacturing or setup, and those values don’t change during regular use. This is why it’s called "read-only" memory—you can only read the data, not write new data to it.

When it comes to building ROM in Terraria, we take a unique approach by using a bunch of stacked on lamps and faulty lamps on top of AND gates. This acts as a sort of multi-layer AND gate that can have multiple inputs in a single gate.


(designed by yfdyzjt)

Breaking It Down:

Breaking it down to a fundamental level reveals just how simple of a concept storage devices are. Most real world and also game re-created ROM storages are designed using AND Gates. AND Gates, as mentioned in the beginning of this guide, require all the inputs to be enabled at the same time for an output to happen, in this case, a single bit.

What is a single bit?
  • On Lamp = Represents a 1 (In binary)
  • Off Lamp = Represents a 0 (In binary)


The main reason AND Gates are ideal for ROM is their ability to have one of their two inputs "programmed" to be either on or off. This makes the AND gate always give a value (either a 0 or a 1) from just a single input. Using Terraria's faulty gate mechanism, we're able to abuse this to actually combine multiple AND gates together into a single AND gate via multiple inputs.



As visualized above, due to the bottom gate being a fully completed AND gate, any on or off lamps stacked above are no longer accounted for within the AND gates function; only the faulty lamps stacked above will cause the bottom AND gate to be triggered.

This means we can actually store multiple bits (4-bits, 4 wire colors) of information within a single 1x3 space by simply touching them to the faulty gates to represent 1 and 0. Let's illustrate how this works below.



As visualized above, this allows for a very compact and efficient means of storing read-only information. This is why ROM has such an advantage over RAM due to it's ability to be so compact. It's important to note that for each input in the example above, I am manually toggling them on and off. If we did not do this, the next row of data would cancel each other out and give the wrong result. This is actually what XOR (Exclusive OR) Data Formatting is used for. It simply accounts for the existing data, alters the desired new information, to ensure that it's correctly outputted as desired. Let's illustrate how this works below.



As visualized above, the output is:
  • on, on, off, off (1100)
  • off, off, on, on (0011)
  • off, off, off, off (0000)
If you take a closer look at the wiring for this, you will see the first row is as normal, both the first two lamps are wired up, but the second row, all four are wired up! By wiring the first two lamps and sending those signals a second time, it's essentially turning their light switch back off after being used. For the third row, we are doing the same thing, toggling off the previous signal.

This methodology is used for many types of sequential storage. As a reminder, this means it can only read data in a +1 and -1 order. To control whether we use the XOR formatting, we simply have to choose what type of serial setup we use, either state or active. For the sake of simplicity, we will use state serial to avoid the XOR wizardry.

Below is illustrating the use of serial and how it works.



As seen above, the light that is on has no wire attached to the faulty lamp, while the one that is off does. Using this mechanic, we can put it all together and "Program" our data to the ROM.



As you can see from the build above, there is 8 AND gates. This means by using all four wire colors, this gives us four sets of 8 bits (1 byte) for a total of 32 bits (4 bytes)!

To add more memory to this there are two options.
  • Option 1: Add more AND gates horizontally to add +1 bit to the output.
  • Option 2: Stack the 1x3 cells vertically to add 32 more bits plus 4 more addresses.
Below is an example of a larger cell.



Sequential ROM

It's important to create a ROM (any storage at large) around the application you need it for. This leads me to what sequential ROM is and what some of its applications are.



Sequential ROM is a type of storage that can only be read in a sequential order, such as forwards or backwards. This memory is very handy for applications such as offloading a set of instructions to a processor or in my case, for displaying animations.

(designed by yfdyzjt)



Non-Random ROM
This is a very advanced and specially created ROM that is non-random. This allows you to navigate around to random addresses just like random access RAM. This is a huge feat as it allows it to be applied to high level applications for circuits such as computers.

(designed by yfdyzjt)


Extra Resources
Designs, and downloads: Terraria Digital Storage[github.com]
Serial Transmitters & Recievers
You have two major methods for transferring data - Parallel and Serial.

As we all know up to this point, connecting a switch to a torch from a single wire is what we call parallel. Think of it as if we had 100 torches and 100 switches that we wanted to wire up individually. Think of the mess that would cause! A solution to this is something called "serial" where we can take the on and off states of the switches and serialize that data over a single wire! This method allows you to transfer infinite amounts of information via one wire. To do this, we need a transmitter and a receiver.

Parallel on the left and serial on the right.


You got two types of serial:
  • If the serial wire is connected to a shorted gate (Dual Activation), then it is state (status) serial.
    • State serial reads data on the receiving end via the the middle logical lamps.
    • State serial remembers it's "status" (Its data) until the next transmission is different.
    • Status serial supports simultaneous reception by multiple receivers.
    • Using state serial makes clearing data very simple.
      Clearing the data is equivalent to writing 0.

  • if it is connected to a normal logic lamp, then it is Active serial.
    • Active serial reads data on the receiving end via the the top logical lamps (Faulty).
    • Active requires XOR data inputs. This means if the next data transmission is the same, it will turn off the existing bits. More over XOR data in the next section.
There is actually more types as well, but these are the two main versions of serial this guide will be covering. It's important while building, you choose a design that best fits your application. However, for simplicity reasons, lets see these two types of devices in action.

First one is "State" (aka status) serial and it is "Continuous," as in the bits are sent in a single go.



Frame by frame breakdown:


The second type is "Active" serial and it sends data in multiple pulses.



Frame by frame breakdown:


Concepts:
Below is a wiring showing the two showcased circuits. As you can see, on the left is the Receiver and the right is the Transmitter. Regardless of design, all serial follows the same principles.


Here is a design of a flush state transmitter and receiver further showcasing the possibilities.



For an instant toggle design, this is a very compact transmitter that can fit in most compact spaces. This type of serial is actually nick named "One-Hot Encoding Serial".



Serial Conclusion:
In conclusion, it's a very useful technology for sending large amounts of data over a very compact space. It's important to note that you can also make vertical transmitters and receivers. It's all about what you need for your build. Another note, and I know many of you have probably noticed this, but these circuits generate smoke. This is completely fine and by design. Smoke in Terraria actually has little to no performance foot prints and causes no harm to your builds if implemented by design.

Below is a great video that helps to explain serial data transfer at a very fundamental level.
XOR (Exclusive OR) Data Formatting
What is XOR?
XOR, or "exclusive OR," is a logical operation that works on binary values (0s and 1s).
It follows these rules:
  • 0 XOR 0 = 0
    (Both bits are the same, so the result is 0)

  • 1 XOR 0 = 1
    (Bits are different, so the result is 1)

  • 0 XOR 1 = 1
    (Bits are different, so the result is 1)

  • 1 XOR 1 = 0
    (Both bits are the same, so the result is 0)
Simplified Explanation
Purpose of XOR:

XOR is used to compare two bits and determine if they are different. It is especially useful in digital electronics and memory devices for tasks like error detection, encryption, and simple data manipulation. In Terraria, it's a very necessary format for data serialization and storing information in a compact manner. When reading data from a storage device such as ROM, the data is transmitted in a Active Serial format so incoming bits of the same value can be flipped and read appropriately. This way instead of losing data like ex: on + on = on, by doing XOR on the data, on + on would = off, thus giving a valid state that can be transmitted and received / decoded.

Application in ROM:

Read-Only Memory (ROM) devices store data that doesn't change. XOR operations can help in certain ROM operations, such as error checking or simple encryption.

Simple Conversion Example of XOR:
Let’s look at a simple example where we convert a 6-bit binary string to understand how XOR works:

Initial Values:
  • Input String: "101101"
  • startingBit always starts with: "0".
This turns our new binary string into "0+101101".

Process Each Bit in the Input String:
  • From here we compare each bit in the input string to the previous bit (starting with the starting bit).
Within "0+101101", the first two char's are 0 and 1.
Using our truth table below, we can check what these values equal.



As you can see, 0 + 1 = 1. So we continue this for the remaining bits.

Bit 1 (Restarting for example reasons):
  • Remaining String: "101101"
  • previousBit: 0.
  • currentBit: 1.
  • XOR Conversion: 0 + 1 = 1.
  • Output String: "1".
Bit 2:
  • Remaining String: "01101"
  • previousBit: 1.
  • currentBit: 0.
  • XOR Conversion: 1 + 0 = 1.
  • Output String: "11".
Bit 3:
  • Remaining String: "1101"
  • previousBit: 0.
  • currentBit: 1.
  • XOR Conversion: 1 + 0 = 1.
  • Output String: "111".
Bit 4:
  • Remaining String: "101"
  • previousBit: 1.
  • currentBit: 1.
  • XOR Conversion: 1 + 1 = 0.
  • Output String: "1110".
Bit 5:
  • Remaining String: "01"
  • previousBit: 1.
  • currentBit: 0.
  • XOR Conversion: 1 + 0 = 1.
  • Output String: "11101".
Bit 6:
  • Remaining String: "1"
  • previousBit: 0.
  • currentBit: 1.
  • XOR Conversion: 0 + 1 = 1.
  • Output String: "111011".
Final XOR Data:
111011
Important! Remember your previous bit as that will be your starting bit for additional binary strings.
  • previousBit: 1.
Additional Conversion Visuals
The graphic below shows the process for converting a 15-bit binary string.


This is showing how the the DEC data of the 3x5 display is bring broken down and aligned into a string of binary that will be converted to XOR and stored into memory. Each 15-bits will be a new conversion who's starting with the leftover previous bit.


Summary
XOR is a fundamental binary operation used in digital electronics.
Purpose: To compare two bits and determine if they are different.
Real-World Use: Error detection, encryption, and digital circuit design.
Transmutation

(The Transmute Workshop by CrypticNight, BEYONDtogether, SpeeQz, Yfdyzjt, putianyi888, ARK Quasar, SpeeQz, Haku, ekinator, VultaxPlayz, Tomo, Pharuxtan, Mikey)

What Is Transmutation?

Before we move on to our next topic of Full 16-Bit RGB Displays, we need to quickly talk briefly of what Transmutation is and it's applications. While this guide is not focused on explaining Transmutation to it's fullest, we will briefly touch on it as it's an important mechanic.

Transmutation is a glitch in Terraria (and other games) that allows you to "transmute" or change one sprite to another sprite; such as a wooden chest, and turn it into a golden chest.



Transmutation in Terraria also allows for the ability to spawn both projectiles and items into the game. One example of this mechanic is the ability to turn a wooden door into a Terra Blade.



This mechanic is what inspired the creation of TWC (Terraria Wiring Community) and turned it into what it is today. From this we have created the famous build, The Transmute Workshop. Here within the Terraria community, Transmutation was originally discovered and founded by Ethyriel and has later been made more public through Icysnowman256. Ethyriel's Handbook[docs.google.com].

How Does Transmutation Work?

Transmutation in Terraria works by abusing how the game renders sprites. Normally, when you turn on a lamp post for example, the game will shift the sprite 18 pixels to the left or right on the sprite-sheet depending on if the lamp is supposed to be on or off.



However, lamp posts are a 1x6 sprite, and if you where to cut away the the button 5 tiles of the sprite, and send an on or off to the post, the game will still attempt to shift the sprite 18 pixels to the left or right. It just so happens that the game does not verify if the sprites within the lamp posts range are ALSO of the same sprite-sheet, and this effectively allows you to manipulate any tile.



As shown above, the lamp post is horizontally shifting the flame trap to face left and right. This change is moving the sprite horizontally by 18 pixels to the left and right.




Infinite Vertical Sprite Movement:

Within Terraria, different sprites have different mechanics, such as a light post turning off and on, or a chimney emitting smoke or not. These visuals are all stored on sprite-sheets and your interactions of these mechanics causes their textures to shift on the sprite-sheets. Depending on the type of mechanic used, it's shifted horizontally or vertically. Most textures in Terraria are stored horizontally, however a few are stored vertically, such as the chimney.



The chimney in Terraria allows for a +3 or -3 vertical spritesheet movement and has a rightwards max range of up to 4 tiles. This means by offsetting the Chimneys top right sprite position (AOE), we can make other textures shift vertically as well.



The chimney on it's own only has 3 states so we can use a monolith to control it's (AOE) movement.



Infinite Horizontal Sprite Movement:

Within Terraria, Lanterns and Lamp Posts (some others) allow for a single horizontal spritesheet movement. This is very useful as it allows for very fine tuned horizontal sprite movement.



By using the following schematic shown bellow, we can create these horizontal sprite shifters.



A very important note is that you can actually control the vertical reach of these modules by how many frames you shift the lamp.



Furthermore, the type of furniture used will determine how many tiles get effected.
  • Lamp Post ===== 6 Tiles
  • Chandelier ===== 3 Tiles
  • Lantern ======== 2 Tiles
  • Lamp + Lantern == 1 Tile
The Lamp + Lantern combination is a very new technology that allows for only a SINGLE tile's worth of space to be allowed to be shifted horizontally.



Advanced Transmutation:

After many advancements in techniques, a 1x1 bi-directional sprite shifter was born. Huge shout-out to quasar128 for the madness behind this.



Transmutation Conclusion:

In conclusion, it's a very useful technology for manipulating and moving sprites around. It has an infinite amount of applications and can be used with many different types of contraptions to make otherwise, impossible mechanics, possible. From vending machines to slot machines, to rotating traps and flying craps, this mechanic can help accomplish many ambitious tasks!

Below is a great video that helps to explain Item Transmutation at a very fundamental level.

Bellow is a video created that goes into depth the creation of the The Transmute Workshop.

Transmutation Glitches Flowchart:

(huge credits to quasar128)
Full 16-Bit RGB Displays
(Rick Astley Never Gonna Give You Up In Terraria 16-Bit Color)

As talked about briefly in the previous section over Displays / Screens, the ability to create a full RGB (Red Green Blue) displays where previously deemed impossible. Very shortly after this guide's release, I was inspired to make it a reality. This section cover's the peak of technological advancement, absurd ingenuity, and puts forth the true testament of our most talented engineers. We will be abusing a glitch covered in the previous section called Transmutation to push the games limits and capabilities.

What Are Wire Bulbs?

For those who are unfamiliar, Wire Bulbs are a light source mechanic added back in 1.3.1 that for each color of wire activated, lights up a different corner of the bulb.



Wirebulbs due to the four colors of wire in Terraria, have 16 unique possible textures. There is technically 32 textures but those textures are currently not achievable without Transmutation, and even with Transmutation, we currently do not have the technology for infinite range vertical shifting.

It's also important to note, the Wire Bulb is unique in that it has more states than any other block.





Solid Pixel Colors Via Texture Packs

As mentioned in the section Displays / Screens, using texture packs, as similarly shown in a video by mattbatwings, you can change the colors of wire bulbs to reflect a solid color. For this, I have created a custom texture pack that solid fills each sprite on the sprite-sheet to it's average color based on the center pixels.
  • You can download it for yourself from the Terraria workshop here.

With this, we can now represent 16-bit colors by Wire Bulbs. The Texture Pack's color pallet can also be changed to better represent the average color spectrum of any desired animation / project.



Changing The WireBulb's Color Without Wires

This brings me to discuss where this idea has rested for some time. As mentioned previously, Wire Bulbs only change their color / sprite with a signal from wires. This mechanic would not allow for a flush display of any kind due to the cross-wire contamination. So in order to combat this, we can use some very advanced Transmutation to change the texture of the Wire Bulb 100% remotely and without any wires needing to be interacting with the Bulb.


(transmutation module designed by quasar128)

As talked about in the previous section over Transmutation, it's actually possible to change the state (color) of a single 1x1 Wire Bulb. Further, it can also be done 100% from a single Lantern + Lamp module for controlling the horizontal 1x1 sprite movement of the Wire Bulb vertically infinity.

Huge thanks to quasar128 once again for his insane talent in Transmutation for actually being able to pull off a miracle and create the module shown bellow.


(transmutation module designed by quasar128)

Creating Flush RGB Displays

By stacking this module and by adjusting the Lantern + Lamp module's vertical reach appropriately, It's possible to have the affected range be flush with the Wire Bulbs display area.


(transmutation module designed by quasar128)

RGB Display Conclusion

With this technology, it's now possible to make a full 120x68 16-bit RGB Displays. It's important to note, that within Vanilla, 120x68 is the max resolution achievable for a 1920x1080 resolution monitor. Huge thanks to yfdyzjt for creating a completed prototype for this!

Below is a video showcasing the worlds first full 16-bit color display In Terraria!.
Adders / Subtractors / Multipliers / Dividers
This section will be to cover adders, subtractors, multipliers, and dividers. These circuits are useful for calculators, computers, and other contraptions that deal with combining numeric values together. Please know, in this section will not be going into much depth as these circuits are fairly complex.

Adder / Subtractor



What is an Adder / Subtractor?

As seen in the illustration above, the switches on the left represent a binary (0s and 1s) input. By inputting a value into the adder, it will output the sums of all switches. Same goes with subtracting; you input your first value into the top left switch, and a value to subtract on the bottom switch. This will present a subtracted value. Adders and subtractors are fairly easy as it's simply shifting the input values based on the inputs.

How it Works:
  • A basic adder is called a "half-adder." It can add two single bits (0 or 1) and produce a sum and a carry output.
  • To add larger numbers, you use a "full-adder," which combines multiple half-adders and includes the carry from the previous bit.



(8-bit adder/subtractor designed by ekinator)

Below is another design by yfdyzjt who created the smallest possible adder / subtractor. It's important to note that this one lays horizontally. Remember to design these circuits around the needed application of your build.



Multiplier

What is a Multiplier?

A multiplier is a circuit that multiplies two numbers together. Multipliers are more complex than adders and subtractors because they typically involve repeated addition.

CSA (Carry Save Adder) Multipliers

What is a CSA Multiplier?

A Carry Save Adder (CSA) Multiplier is an advanced circuit that multiplies two numbers efficiently by using a series of adders in a specific configuration. The CSA method is particularly useful for speeding up multiplication in digital circuits.

How it Works:
  • Basic Idea: Instead of performing traditional binary multiplication (which involves shifting and adding), a CSA multiplier uses multiple adders to combine partial products in parallel.
  • Carry Save Adder: The key component is the Carry Save Adder, which adds three numbers at a time but "saves" the carry to be processed later, instead of propagating it immediately. This allows the multiplication process to be faster.


(8-bit CSA (Carry Save Adder) multiplier designed by yfdyzjt)

Divider

What is a Divider?

A divider is a circuit that divides one number by another. Division is one of the more complex operations in circuits.

Non-Restoring Dividers

What is a Non-Restoring Divider?

A Non-Restoring Divider is an advanced circuit that divides one number by another using a specific division algorithm. The non-restoring method is an efficient way to perform division and is often used in digital electronics.

How it Works:
  • Basic Idea: Non-restoring division iteratively subtracts the divisor from the dividend, but unlike simple division, it checks the remainder after each subtraction and adjusts the quotient accordingly.
  • Steps:
    • Initial Setup: Start with the dividend (number to be divided) and divisor (number to divide by).
    • Shift and Subtract: Shift the divisor to the left (like multiplying by 2) and subtract it from the current value of the dividend.
    • Check Remainder: If the remainder is positive, record a 1 in the quotient and repeat the process. If it's negative, add the divisor back and record a 0.
    • Continue: Repeat until all bits of the dividend have been processed.
    • Final Adjustment: The result is the quotient, and the remainder is left as the remainder of the division.


(Non-restoring 8-bit Divider original design by ekinator, redesigned by yfdyzjt)
The NPC Housing Performance Bug
This is a not so much known bug, but by not having all the NPC's in your world, it can actually cause severe lag spikes. This bug seems to have the most severity on larger worlds.

This bug is caused by a stackoverflow or "infinite loop" of searching for valid NPC move in conditions. Any time you lag for no reason, then an NPC moves in and it magically goes away, this is why. "Because it is necessary to check the NPC room several million times." - a bad joke.

(Found by yfdyzjt. Software: JetBrains dotTrace[www.jetbrains.com])

The Solution:
The solution to this is super simple. You simply need to build and populate valid housing for all the NPCs. It's definitely a hassle, but it's a sure solution to prevent this from happening.

Accelerating The Wiring
Due to how the Terraria logic system is, larger wiring builds will freeze your game each time you power them up. To fix this, we can use a mod called the Terraria Circuit Preprocessing Accelerator[github.com] to pre-process the wiring and prevent lagging while still maintaining the vanilla logic system.


Credits / More Technical Guides
Congratulations for getting to the end of this guide! You should now have a solid understanding on the fundimentals on logic gates, circuits, fundimental, and the computer science behind it! For anyone who's still hungry for more material and possibly some higher level concepts and science, I would have to 100% recommend you to check out the TerrariaWiringTutorial created by putianyi889[github.com].

Chinese Version (Original Post):
Terraria Wiring Tutorial[github.com].

English Version (Mass Google Translated):
Terraria Wiring Tutorial[github.com].

Huge thanks to the Terraria Wiring Community (TWC discord) for all the help and brains.

We would like to welcome to new members to join us as well! Whether you're a seasoned engineer of Terraria's intricate wiring systems or a curious newcomer eager to dive into the world of technical wizardry, you will find yourself at home here at TWC! Our community is built on a foundation of collaboration, learning, and sharing. Here, you'll connect with like-minded players, master the art of wiring, and unlock the full potential of Terraria’s mechanics. If you are interested in joining, feel free to click the following link to our Official Discord Server: https://discord.gg/gHWA2SvVcd



You're also welcome to add and direct message me on Discord for an invitation: dannyruss


(The Transmute Workshop by CrypticNight, BEYONDtogether, SpeeQz, Yfdyzjt, putianyi888, ARK Quasar, SpeeQz, Haku, ekinator, VultaxPlayz, Tomo, Pharuxtan, Mikey)


(Tetris by yfdyzjt[space.bilibili.com])

Huge Thanks!
With the circuits and devices covered in this guide, you now have a solid foundation to build more complex and interesting wiring setups. The possibilities are vast, so experiment, iterate, and innovate as you integrate these designs into your builds. Have fun, stay motivated, and happy wiring! This guide has been a compilation of 12+ years worth of Minecraft & Terraria logic knowledge.

This guide has been written in it's entirety by CrypticNight and revised by SapphireRose.
7 Comments
CmeTaNa 27 Aug, 2024 @ 8:38pm 
ty bro
Mike_musa 24 Aug, 2024 @ 11:55am 
Jesus christ that is long (I ain't reading allat but why can you make a working PC in terraria)
𝔞𝔟𝔰𝔬𝔩𝔲𝔱𝔢 24 Aug, 2024 @ 9:20am 
123
Eb_siffers 24 Aug, 2024 @ 4:03am 
truly a masterpice!
Ilon(^_^) 22 Aug, 2024 @ 11:35am 
this is insane good work
DontaeRiceArt (DMR) 21 Aug, 2024 @ 10:47pm 
Thanks for the shoutout on the map! I'll be keeping this bookmarked and sharing it around :steamthumbsup:
Kuz_ 21 Aug, 2024 @ 10:40pm 
This guide is absolutely a work of art!