An Official Introduction to Terrarian 1.3.1 Wiring & Mechanics

X'o'Lore

Terrarian
Lots of really cool stuff. I'm pretty excited to have logic gates, though the stateless nature of Terrarian wires still makes some things a bit clunky even with all this.

I've had cases where I had multiple devices with individual triggers for each one and wanted a sort of master toggle that would switch them all to an explicit on/off state so they were either all on or all off regardless of their former mixed states. This seemed pretty hard to do before and I had to resort to bulky and exotic rigs attached to each device to do. It also introduced delays with the extra mechanics on each device. I could probably do it easier now with dart traps using the projectile pads and an actuated block I think, but it'd still be a bit awkward.

Some sort of state-gate that passed an on/off param to all devices it activated to put them all in an explicit state would be quite handy. I guess I'll keep it on my wish list. A shame I missed the request thread for this patch.

You give people nice things and it only fills them with a desire for even more I guess.
 

Niranufoti

Plantera
If I'm not mistaken, isn't that the NAND gate?
Nope. NAND is just "not all" (without the "any" part), so 0 NAND 0 is 1, whereas (0 OR 0) AND NOT (0 AND 0) is 0.

This was possible to construct in pre-1.3.1 by connecting any number of switches/pressure plates to a wire connected to an output :). So long as there are an odd number of inputs the output is always 1. We now have a dedicated gate for this function, but it might be easier to just use the previous approach.
Yeah, that's what I said - a diode. And now it's even easier more practical since we don't have to connect three different wires to one output, but can connect three wires to one Logic Gate Lamp above an OR gate and just lead one wire from there to the output.
That aside, it was already possible to create all of these logic gates with a bit of voodoo and just a slight delay - this update basically just makes everything more practical and more compact. Also, we no longer need to have a hundred dummy ghosts standing around.
 

Yoraiz0r

Lead Developer
Re-Logic
According to my sources (i.e. Wikipedia and common sense), polyadic XOR would be "addition modulo 2", that is, the output is 1 if an odd number of inputs is 1. That's what you get when evaluating a chain of A XOR B XOR C XOR ... XOR N in any order. Of course it's useful to have a =1 gate, since as I outlined previously, unless an even number of inputs of the XOR (addition modulo 2) gate are toggled (receive a pulse) at the same time, any change in input causes a change in output (a pulse), so in Terraria's pulse-based system, it's effectively the same as a diode. Still, maybe it shouldn't be called an XOR gate, and the XOR gate should be implemented seperately (if at all).
Also, while we're at suggesting new gates, an "any but not all" gate would be nice as well. Then we'd have three gates that would work the same with two inputs, but work differently at higher levels.
Though, then again, anything other than the current "=1" XOR gate could be constructed rather easily.
Thank you for the clarification, I don't think I'll change the XOR we have right now in terms of functionality, I might look into updating its name / consider adding a new one :)

P.S. Did anyone get familiar with the faulty logic lamps yet?
 

Niranufoti

Plantera
P.S. Did anyone get familiar with the faulty logic lamps yet?
I think I got it, but I'm not certain yet.
What gate is used doesn't matter as far as I can tell; neither do lamps placed above the faulty one.

When the faulty lamp gets a signal, the gate is randomly activated with a certain chance. This chance seems to be determined by the logic gate lamps below the faulty one, more specifically (number of active lamps)/(number of total lamps), e.g. if you have three active ones and one inactive one between the faulty lamp and the gate, there's a 75% chance of activation.
 

FelixNemis

Terrarian
I think I got it, but I'm not certain yet.
What gate is used doesn't matter as far as I can tell; neither do lamps placed above the faulty one.

When the faulty lamp gets a signal, the gate is randomly activated with a certain chance. This chance seems to be determined by the logic gate lamps below the faulty one, more specifically (number of active lamps)/(number of total lamps), e.g. if you have three active ones and one inactive one between the faulty lamp and the gate, there's a 75% chance of activation.

Oh if that's how they work that sounds pretty handy

Here's a super compact RS latch I made using them
17irDqv.gif


Edit: One thing that would be super nice to have is the ability to attach the logic gate lamps to the bottom of the logic gate, that might require changing too much though
 

Niranufoti

Plantera
Oh if that's how they work that sounds pretty handy

Here's a super compact RS latch I made using them
-img-
holy:red:youjustsavedmealotoftrouble

No, seriously, I was currently thinking about how to create transistors, and you just put it right there.

Thanks for pushing us towards the faulty ones, Yorai :D
 

Yoraiz0r

Lead Developer
Re-Logic
NiraExecuto, your understanding of their works is correct =P
You can also chain them to make a counter, and do other neat things.
I would have gone and added a section of example uses for those, but I am busier working on the update's hotfixes at the moment.

Quick random technical nitty-gritty
Gates are only once a whole set of 4 wire colors finishes spreading the wire hits.
Gates can only be activate once per an entire wire "tour". (so if a gate has to pulse 2 or more times, it will not, to avoid infinite loops) (but they do change their state, so it doesn't end up wrong)
Lamps are updated as soon as they're hit, so if a normal lamp is hit first and then the faulty lamp, chained around multiple times, you can have a counter =P
 

Niranufoti

Plantera
NiraExecuto, your understanding of their works is correct =P
Oh come on, I just finished poking around inside the decompiled source code and then, of course, you just have to come and ruin everything before I can start boasting...

Though I have to wonder - why are the gates in the order AND, OR, NAND, NOR, XOR, NXOR? Switching OR and NAND would make a lot more sense :p
 

Yoraiz0r

Lead Developer
Re-Logic
Oh come on, I just finished poking around inside the decompiled source code and then, of course, you just have to come and ruin everything before I can start boasting...

Though I have to wonder - why are the gates in the order AND, OR, NAND, NOR, XOR, NXOR? Switching OR and NAND would make a lot more sense :p
Order of implementation, when we started I only wanted to test AND and OR :)
 

pbq

Terrarian
Thank you for explaining how faulty lamp works. Now, back to testing! There is science to be done!
 

Attachments

  • Capture 2016-05-23 19_21_47.png
    Capture 2016-05-23 19_21_47.png
    22.7 KB · Views: 407

FairyPrincessSerenity

Empress of Light
P.S. Did anyone get familiar with the faulty logic lamps yet?

I think I got it. I've been testing it out on an AND Logic Gate. The probability of a faulty gate is determined by the regular lamps below it. The more that are lit, the more likely the faulty gate will work. It seems to also override the need for all of the gates to be lit to operate the AND Gate.
So if there is a pair of lamps; one on and one off, the faulty one sitting on top of the pair will work around 50% of the time.
If there are eight lamps; one on and seven off, the faulty one on top of that stack will activate the gate 12.5% of the time.
So logically, you could chain a bunch together to trigger an event with an abysmally low probability of happening.

Improbable Machine.png


This thing will never light up the torch. It works just fine. It's just... too improbable.
 

Purple Ninja

Terrarian
I have no regrets for taking electronics back in high school.

Can't wait to see what crazy stuff you geniuses come up with :) Nice patch Re-logic :)
 

DrIgnispirus

Steampunker
I think I've discovered something - the logic gates don't just send a "pulse" when their condition is true - they also send one when it becomes false. Am I right?
 

Niranufoti

Plantera
I think I've discovered something - the logic gates don't just send a "pulse" when their condition is true - they also send one when it becomes false. Am I right?
Yeah, that's the idea, so that when you connect a device (e.g. a door) to the gate, it turns on (opens) when the gate activates and turns off (closes) when it deactivates.
 

DicemanX

Brain of Cthulhu
I think I've discovered something - the logic gates don't just send a "pulse" when their condition is true - they also send one when it becomes false. Am I right?

Yes, except in the cases of infinite loops created by hooking up the logic gate box back onto one or more of the lamps above it. In such instances the infinite loop is avoided by shutting off the box and the lamp(s), which means that the box fails to send a signal when it shuts off.

I'm not sure yet whether this always works this way, but from testing so far that's what I observed.
 

Niranufoti

Plantera
Yes, except in the cases of infinite loops created by hooking up the logic gate box back onto one or more of the lamps above it. In such instances the infinite loop is avoided by shutting off the box and the lamp(s), which means that the box fails to send a signal when it shuts off.

I'm not sure yet whether this always works this way, but from testing so far that's what I observed.
There's no "infinite loop detection" or anything, it's just that if a gate has already sent a pulse this tick, it won't sent any more pulses, even if it's toggled more than once. It doesn't necessarily have to be hooked up to itself, and if I'm not mistaken, it doesn't necessarily turn off either - it just switches to the state it's supposed to without sending any signal.
 

Yoraiz0r

Lead Developer
Re-Logic
There's no "infinite loop detection" or anything, it's just that if a gate has already sent a pulse this tick, it won't sent any more pulses, even if it's toggled more than once. It doesn't necessarily have to be hooked up to itself, and if I'm not mistaken, it doesn't necessarily turn off either - it just switches to the state it's supposed to without sending any signal.
That is correct - though the original purpose was to avoid infinite loops. :p

Another caveat is that weighted pressure plates placed on teleporters would cause a semi 'infinite loop' when stepped on, given that as soon as you press them in a teleporter you would teleport somewhere else - and then they get pulsed again while you're on the other end, sending you back to the original point - we stopped it by exclusively stopping this particular interaction between the plates and the teleporters.
 
Top Bottom