Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

逻辑门

来自Terraria Wiki
跳转至: 导航搜索
此页面的(部分)内容需要被翻译。
你可以帮助我们来翻译此页面
逻辑门
  • 逻辑门的物品外观
Stack digit 9.pngStack digit 9.pngStack digit 9.png
属性
类型机械家具
可放置是 1 格宽 × 1 格高
使用时间14 很快速度
稀有度稀有度级别:1
买入2 金币
卖出40 银币
电脑版 电脑版独有内容:此的信息适用于电脑版泰拉瑞亚
Example of the logic Gate AND.

A 逻辑门 is a 机械 used to provide logic to wiring setups. Input is provided using a stack of 逻辑门灯s placed on top of it. The logic gate turns on and off depending on its inputs, and emits a signal every time its state changes.

The Logic Gates, along with the Logic Gate Lamps, are purchased from the 蒸汽朋克人 for 2 金币 each.

行为[编辑 | 编辑源代码]

All gates are turned off when they are first placed. Whenever a lamp is added or removed or one of its lamps changes state, the logic gate updates according to the following rules:

  • Logic Gate (AND).png AND: Turns on when all lamps are active.
  • Logic Gate (NAND).png NAND: Turns on unless all lamps are active.
  • Logic Gate (OR).png OR: Turns on when at least one lamp is active.
  • Logic Gate (NOR).png NOR: Turns on when no lamp is active.
  • Logic Gate (XOR).png XOR: Turns on when exactly one lamp is active.
  • Logic Gate (XNOR).png XNOR: Turns on when the total active lamps is not one.


Whenever a logic gate is turned on or off it emits a signal. If this signal would cause a logic gate to change its own inputs and emit two signals on the same tick, instead a puff of smoke is shown at the gate and only one signal is emitted. Note that while only one signal is emitted, the state of the logic gate itself still changes.

Faulty Lamps[编辑 | 编辑源代码]

Placing a faulty logic gate lamp above a logic gate turns it blue, overriding its normal functionality and changing its behavior entirely. The logic gates function as a randomizer instead, and can no longer turn on or off. The gate no longer emits signals when normal logic lamps above it change state. Instead, when the faulty lamp is triggered by a signal, it randomly selects one of the logic lamps below it. If that lamp is on, the logic gate emits a signal. So, if there are three lamps below the faulty lamp, two ON and one OFF, the gate has a 2/3 chance to emit a signal when the faulty lamp is triggered.

A faulty lamp can be triggered multiple times in one tick, effectively giving the gate multiple chances to emit a signal. Multiple signals cannot be emitted on the same tick this way, however, the gate will have a chance to emit a signal for every time a faulty lamp receives a signal. For example, if you trigger a faulty gate with one out of two of its logic gate lamps on twice in the same tick, it will have an 3/4 chance of emitting a signal.

Faulty lamps continue to work if only one logic gate lamp is under it. In this case, the logic gate as a whole acts as an "if" statement, only passing a signal through if the single lamp is on. If no logic gate lamps are attached, the logic gate never sends signals when the faulty lamp is triggered. A very practical use of this is a one-way wire: when a logic gate receives a signal it does nothing, but triggering the faulty lamp above it does send a signal. The logic gate lamp under the faulty lamps needs to be on. Also, this wire can be turned off by sending a signal to the logic gate lamp. Making two of these lets the player control all four possible states of a wire: Off, on (A->B), on (A<-B), on (A<-->B).

Inverted Gates[编辑 | 编辑源代码]

Since gates emit a signal whenever they either turn on or off, the "inverted" versions of each gate (those with an "N" prefix) behave identically to their normal counterparts in most situations. The only difference is when the first lamp is added to a new gate. (For example, both the NAND and AND gates start off when first placed. However, upon adding an off gate, the AND gate would stay off and emit no signal while the NAND gate would turn on, thus emitting a signal.)

Useful Circuits[编辑 | 编辑源代码]

set/reset flip-flop (SR flip-flop)[编辑 | 编辑源代码]

A set/reset flip-flop is a device that has two inputs, and can be switched between the two. However, multiple activations on the same input will not change the state. It will output a pulse when the state changes. In the illustration, red and blue are the inputs, and green is the output.

备注[编辑 | 编辑源代码]

  • NOT gates are not in the game as they would simply emit a signal every time an input changes due to how logic gates work in Terraria. A NOT gate can be created with a NAND gate and wiring both inputs together.
  • Multiple faulty lamps can be attached to a single logic gate, all of which will cause the gate to output a signal. However, only logic gate lamps below the lowest faulty lamp in the chain affect the chance of the logic gate emitting a signal. Any above it are ignored.

历史[编辑 | 编辑源代码]

  • 1.3.2:Fixed XNOR being named NXOR.