[tModLoader] Logic Gates Mod

Smiffy

Skeletron Prime
Logic Gates Mod

Current Version: v0.1.1
tModLoader Version: v0.3.0.1
After seeing some of the crazy wiring mechanisms on places such as TMEC and Youtube, I has a thought about how much different it would be if logic gates were easy to implement into your wiring (or at least a lot easier than what we currently have). So I made this mod, with the hopes to add logic gates and other useful wiring components into the game.

Credits:

Re-Logic for creating Terraria
bluemagic123 for creating tModLoader and for a bit of help with the wiring code.


Current Features:
  • Logic Gate base (crafted with two Iron bars and one wire at an anvil), used to craft the components of this mod (not placeable).
LogicGate_Base.png

  • OR gate (crafted with 3 Logic Gate bases at an anvil). If either of the two states of the gate are toggled on, the gate outputs a signal.
LogicGate_OR.png

  • AND gate (crafted with 3 Logic Gate bases at an anvil). If both of the two states of the gate are toggled on, the gate outputs a signal.
LogicGate_AND.png



Planned Features:
  • XOR gate. If both of the two states of the gate are different (either 1 & 0 or 0 & 1), the gate outputs a signal.
  • Repeater. Outputs a signal some amount of time after an input is received. Most likely crafted with Logic gate bases and timers / watches.
  • Taking suggestions!

How it works:

Each logic gate is a 3x2 TileObject (piece of furniture) that takes an input from the bottom-left and bottom-right. The gate's output is the top middle. I have set this up so that the logic gate works without having to use multiple colours of wiring. When a signal goes into one of the inputs, that side's state toggles (just like a torch does when you give it a signal). When one of these states changes, that is when the gate will output a signal if the conditions are met.

5sQ0qBp.png




Current Issues (working on, suggestions on how to fix these are welcome):
  • Currently it is rather difficult to tell whether a state is activated or not. You may want to add torches to the wiring on both the inputs and the output of each gate to identify what side is activated or not.
  • Sprites. I am not a very experienced spriter, but I have tried my best. I have tried adding symbols to the logic gates themselves to help identify what kind of gate they are but they are still rather tiny, so it may be difficult for some people to tell what the gates are without looking on the map or picking them up.

Download: Version 0.1.1

Changelog:

Version 0.1.1
  • Fixed a bug involving wiring two inputs of a gate on the same wire (thanks billybao).
  • Gates should now display wires when held.
Version 0.1
  • Initial WIP release

Any suggestions for features or improvements are welcome. Also post any problems you may find. Hopefully the very first release won't break.. hopefully.

 
Last edited:
It's a pretty useful mod for wiring and mechanics, but I have found some problems:
1. Make wires visible when holding the logic gates! This is very important in my opinion.
2. The gates seem to work fine at the start, but after a while I came up with this:
Capture 2015-08-05 20_31_22.png

Capture 2015-08-05 20_31_40.png

The bottom gate is an OR, and the top one is an AND.
It works normally, but then I changed the top gate into an OR, then tried any of the switches.
Then this happened, I right clicked and held on the switch, and heard lots of triggers, like the switch was toggling every tick.
Also notice my speed indicator on the right. It says "0 mph" now...
2015-08-05_00004.jpg

2015-08-05_00005.jpg

2015-08-05_00006.jpg

2015-08-05_00007.jpg

When I hold it for a while, my speed goes up to 51 mph (which is really fast, since Hermes Boots gives ~36mph), even though I'm not moving.
Then when I release the right button, my char goes super fast (51mph?) for a split second then goes down to 0 because I'm not pressing any movement keys.

After that, I discovered that monsters can't hit me if I hold the switch:
2015-08-05_00008.jpg

...That's cool, I guess.
Sometimes simply exiting+reentering the world(and change the top gate to an AND gate) fixes the issue. Other times I had to close the game and reopen.


If anyone is wondering, I'm using 1.3.0.7 with tModLoader 0.3.0.1, using this mod along with the tModLoader's example mod.


~~~~~~~~~~~~~~~~~~~~Just trying to post a helpful bug report!~~~~~~~~~~~~~~~~~~~

Edit: Just realized that it's a very long post, so I put it in a spoiler.:)
 
Last edited:
It's a pretty useful mod for wiring and mechanics, but I have found some problems:
1. Make wires visible when holding the logic gates! This is very important in my opinion.
2. The gates seem to work fine at the start, but after a while I came up with this:
View attachment 68780
View attachment 68781
The bottom gate is an OR, and the top one is an AND.
It works normally, but then I changed the top gate into an OR, then tried any of the switches.
Then this happened, I right clicked and held on the switch, and heard lots of triggers, like the switch was toggling every tick.
Also notice my speed indicator on the right. It says "0 mph" now...
View attachment 68784
View attachment 68782
View attachment 68783
View attachment 68785
When I hold it for a while, my speed goes up to 51 mph (which is really fast, since Hermes Boots gives ~36mph), even though I'm not moving.
Then when I release the right button, my char goes super fast (51mph?) for a split second then goes down to 0 because I'm not pressing any movement keys.

After that, I discovered that monsters can't hit me if I hold the switch:
View attachment 68786
...That's cool, I guess.
Sometimes simply exiting+reentering the world(and change the top gate to an AND gate) fixes the issue. Other times I had to close the game and reopen.





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Just trying to post a helpful bug report!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks a lot for this. I thought I had the logic gates show wires when held, but I forgot to add it to the OR gate. I am looking into the other issues. What other mods do you have installed?
 

I have managed to recreate the odd behaviour, and it is really odd indeed. I will hopefully release a fix soon.

Edit2: I found the fix and will upload the new file & update OP soon. Thanks for taking the time to demonstrate the bug!
 
Last edited:
Really cool! This reminds me so much of me playing Minecraft in the past, and fiddling around with redstone. +1 from me!
 
I have managed to recreate the odd behaviour, and it is really odd indeed. I will hopefully release a fix soon.

Edit2: I found the fix and will upload the new file & update OP soon. Thanks for taking the time to demonstrate the bug!


Great! I'm just glad you found a way to fix it!
 
That page was the reason that after a lot of time lurking around I decided to join these forums.

Firstly, I want to say good job. Haven't tried it out yet but probably I will soon. I'm currently making a map for terraria the ultimate style. Not locking you out of any parts of the game (ie corruption or crimson or pyramids by having everything), by having multi-colored dungeon etc mostly for personal use. I also wanted to make it an adventure style map by having to solve puzzles in dungeons and other places, making everything make sense (for example no ice biome next to a desert one, or the houses in the dungeon serve purpose) etc etc.

Now for the puzzles I did not want to make simple platforming so I started looking into terraria's wiring and IF it is possible to make logic gates using the vanilla wires which proved WAY too difficult if at all possible and then I saw this mod. It would certainly make my life a lot easier but I'm still not sure if I'll use it mainly because IF I decide to release the map to public I don't want them to have to download external mods.

But I sure will have it for my personal adventures.... Just a quick question tho'. If you're not planning on adding every logical gate (judging from your todo list) why did you not make the two universal gates aka NAND/NOR? Or even just one of them? Less work for you and people that used it would be able to create any logical gate they needed using only a NAND or a NOR in different configurations.
 
But I sure will have it for my personal adventures.... Just a quick question tho'. If you're not planning on adding every logical gate (judging from your todo list) why did you not make the two universal gates aka NAND/NOR? Or even just one of them? Less work for you and people that used it would be able to create any logical gate they needed using only a NAND or a NOR in different configurations.

The problem with Terraria's wiring is that it doesn't simulate a current, it only uses pulses to activate things. That means that there really isn't an "off" and "on" wire state (only "off"). I was planning to do a NOT gate and NAND/NOR/XNOR, however I am not quite sure what the best way to implement them is right now. Once I get the behaviour of all the gates finalized I can decide whether inverted gates are worth putting in.
 
So you made those two by using simply the off state?

I thought you modded the system to use a simulated current in order to make those instead of using the vanilla system. I'd offer help with it but right now I'm right in the middle of moving to a new country plus I have no idea how to cook logic gates by using only an off state unless the not "off" can be used as "on" in the code
 
So you made those two by using simply the off state?

I thought you modded the system to use a simulated current in order to make those instead of using the vanilla system. I'd offer help with it but right now I'm right in the middle of moving to a new country plus I have no idea how to cook logic gates by using only an off state unless the not "off" can be used as "on" in the code

Nope, I made the gates use the vanilla wiring system. Sending a pulse to an input toggles that side's state (from on to off, or from off to on). Currently the gate outputs a signal when an input pulse is received on either side, and the gate's conditions are met.
 
That page was the reason that after a lot of time lurking around I decided to join these forums.

Firstly, I want to say good job. Haven't tried it out yet but probably I will soon. I'm currently making a map for terraria the ultimate style. Not locking you out of any parts of the game (ie corruption or crimson or pyramids by having everything), by having multi-colored dungeon etc mostly for personal use. I also wanted to make it an adventure style map by having to solve puzzles in dungeons and other places, making everything make sense (for example no ice biome next to a desert one, or the houses in the dungeon serve purpose) etc etc.

Now for the puzzles I did not want to make simple platforming so I started looking into terraria's wiring and IF it is possible to make logic gates using the vanilla wires which proved WAY too difficult if at all possible and then I saw this mod. It would certainly make my life a lot easier but I'm still not sure if I'll use it mainly because IF I decide to release the map to public I don't want them to have to download external mods.

But I sure will have it for my personal adventures.... Just a quick question tho'. If you're not planning on adding every logical gate (judging from your todo list) why did you not make the two universal gates aka NAND/NOR? Or even just one of them? Less work for you and people that used it would be able to create any logical gate they needed using only a NAND or a NOR in different configurations.


Hi atheran12!

If you're looking for a way to make logic gates using vanilla wire, I saved a thread from Terraria Online, though I couldn't remember the link...
It's in the attachment. The gates do take up some space though, so you'll have to design your map cleverly to use this method. That's why this if this mod works, it would be great, since it allows for much more compact puzzle designs.:D



P.S. I just discovered that the forums don't allow Word documents, but allow ZIPs. Strange......:eek:
 

Attachments

  • Gates.zip
    1.2 MB · Views: 316
Back
Top Bottom