Logic gates - by Preach (andrew.denner@btinternet.com)

The map file included here demonstrate the logic gates explained in detail at

https://tomeofpreach.wordpress.com/2013/05/13/new-logic-gate-design/
and
https://tomeofpreach.wordpress.com/2013/05/15/new-logic-gates-part-two/

This file copntains one of each of the gates, isolated in the lower 4 boxes. Above each
box is an example entity setup you can use to test the gates. The boxes the gates are contained in are quite oversized, hopefully this will make it easy to examine the inner workings of each gate and copy-paste them into your own map. The boxes can be shrunk to fit the gates in your maps but remember that each gate must be isolated in its own box, and never exposed to the void.

What do the four gates do?

Gate 1:

This is a basic toggle gate. It can be toggled open or closed, by triggering the events named "open_gate1" and "close_gate1" respectively. When open, it works like a trigger relay, so triggering the event "query_gate1" will lead to the event "output_gate1" being fired. When closed, triggering the event "query_gate1" does nothing.

Gate 2:

Gate 2 has two subgates, opened by "open_gate2a" and "open_gate2b" and closed by "close_gate2a" and "close_gate2b. This time, the event "query_gate2" will only cause "output_gate2" to be fired if BOTH gate2a and gate2b are open. This means Gate 2 is an AND Gate.

Gate 3:

Gate 3 also has two subgates "open_gate3a"/"close_gate3a" and "open_gate3b"/close_gate3b". The difference this time is that "query_gate3" fired if EITHER of the subgates are open, making this an OR Gate.

Gate 4:

Gate 4 differs from the previous gates because triggering "query_gate4" will always cause another event to be fired, but it has two possible outputs: "output_gate4a" and "output_gate4b". Firing the events "toggle_gate4a" and "toggle_gate4b" will select which of these events is output. In the blog post above, this is the IF-ELSE gate.

You can see how all of these work in-game by compiling and loading the map. The various side buttons in the upper level toggle the states of the gates, and the central buttons will trigger a door conditional on the gate in question being open.