User:Darkid/Sandbox

From Valve Developer Community
Jump to navigation Jump to search
Portal 2 Puzzle Maker

Some portal puzzles may require more complex logic than the game initially allows. The simplest types of logic offered by the game are the NOT gates as well as the AND gates.

NOT gates

This is a NOT gate

NOT gates the simplest type of logic, as they only use one input. These gates are implemented by default, by simply changing whether the target starts enabled or disabled.

AND gates

This is an AND gate

AND gates are also implemented into the code by default. Whenever two buttons are connected to a single output source, the output source will only enable once both inputs are enabled. A NAND gate can be implemented by flipping the initial state of the output, as per a NOT gate.

OR gates

OR gates are the simplest logic not hard-wired into the game. There are two ways of creating an OR gate, one requiring lasers and one not.

With lasers
The simpler form of an OR gate simply uses two lasers pointed at a floor-mounted laser relay. Thus, if either laser is on, the floor relay is also on. This can then be hooked up to an exit.
Without lasers
However, due to the tendency of lasers to lag a game, it may be better to build such a setup without using lasers. This is one of the few gates that is not as easy to create without lasers. In this setup, both inputs are inverted, fed into an AND gate, and the output is then inverted.

XOR gates

This is an XOR gate

An XOR gate is the most complex of these gates. It should only be active if one of the two inputs is active, but not both. It requires a combination of two AND gates, one NOT gate, and one OR gate. The logic is as follows: Combine both inputs into an OR gate. Simultaneously combine them into an AND gate. If the OR returns true AND the AND gate returns false, then return true.