|Name of gadget||XOR gate|
|Section||Logic & Processing|
|Number of Tweak pages||1|
|Last updated||22 Feb 2019|
This gadget analyses two or more signals and produces a true signal if only one of them is true. You would use this to activate something when exactly one and ONLY one of a selection of conditions needs to be true for an action to happen. You can add up to 10 conditions to this gadget (see tips below if you need more).
The classic example use for the XOR gate is for a pair of light switches, one at each end of a flight of stairs. If you flick one of them, it will always change the number of true inputs between 1 (true) and [0 or 2] (both false) or vice versa, therefore allowing you to toggle a light on and off from either switch. (Note, however, that this won’t work well for three or more switches connected to the XOR gate. Can you see why? More tips below…)
Example Tutorial (adapted from Media Molecule)
- Place a light
- Place a controller sensor
- Place a trigger zone
- Place a puppet
- Place an XOR gate
- Connect detected on the trigger zone to the A input.
- Tweak the controller sensor and make it remote controllable
- Connect the square output on the controller sensor to the B port on the XOR gate.
- Connect the result output of the XOR gate to the power port on the light
- Go to test mode.
- Press the square button. The light will come on.
- Possess the puppet.
- Run into the trigger zone and the light comes on.
- Now try pressing the button while in the trigger zone. The light does not come on.
- No. of Ports
Select how many inputs you are comparing here. The ports are activated in strict sequence from top to bottom, A to J.
Wire your inputs into each port. An active port with no input will default to a “false” signal, though this is unimportant because one extra “false” signal won’t change the count of “true signals”.
This will produce a signal of true (1) if one and only one of the attached inputs is true (1).
This is where you can turn the gadget on/off
- Use each condition to set whether a tag is active.
- A trigger zone can return the number of tags it detects from its Number Detected output.
- Make sure the trigger zone’s Number Required is more than 1 or you’ll end up with an OR gate!
- Use a calculator to check whether this number is Equal To 1.
Coming back to the “multiple light switches” example mentioned in the introduction, if you want to have more than two switches, all of which can turn a light on and off, what you really need is an “odd number detector”. This can also be achieved with the above method, only you would use the calculator to check if the number of active tags leaves a remainder when divided by 2.
However a really neat trick is to wire 2 or more two-input XOR gates in sequence (they MUST be two-input only!) in the following manner (we’ll get a real Dreams screenshot once the Creator Early Access is available):
… and you can repeatedly add new inputs by extending this pattern downwards, one XOR gate for each input. The output is true when the number of inputs is odd. If you can’t easily see why this works, try it out for yourself!