From Valve Developer Community
Jump to: navigation, search

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.

An alternate XOR gate

An alternate method involves two excursion funnels. By causing them to intersect, they will hold an object in between them in stasis, preventing it from moving. However, if only one funnel is on, the object will hit an appropriate button. If neither is on, it will fall to the floor. By using an OR gate on the two outputs, this forms an XOR gate. Note: You must use an edgeless safety cube for this, as a normal cube is too large, and may accidentally enable a button while both funnels are on.