逻辑门

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

逻辑门是提供线路逻辑的机械。使用一个或多个逻辑门灯放在逻辑门上做为讯号源。逻辑门的开关状态视其输入源而定,且每次改变状态时会发送一次讯号。

逻辑门每个20000*2 Gold Coin.png,与逻辑门灯都出售自蒸汽朋克人

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

所有的逻辑门在初次放置时都会是关闭状态。每次加入、移除、或开关逻辑门灯,逻辑门会依以下规则行动:

  • Logic Gate (AND).png AND: 所有灯都亮时,输出讯号。
  • Logic Gate (NAND).png NAND: 除非所有灯都亮,否则输出讯号。
  • Logic Gate (OR).png OR: 至少一个灯亮时,输出讯号。
  • Logic Gate (NOR).png NOR: 没有灯亮时,输出讯号。
  • Logic Gate (XOR).png XOR: 只有一个灯亮时,输出讯号。
  • Logic Gate (XNOR).png XNOR: 不是正好一个灯亮时,输出讯号。


无论何时逻辑门打开或关闭,它都会发出一个信号。如果这个信号会导致一个逻辑门改变它自己的输入,并在同一时刻发出两个信号,那么相反,在这个逻辑门上会显示一股烟雾,并且只发出一个信号。注意,虽然只发出一个信号,但逻辑门本身的状态仍会改变(逻辑门输出信号使逻辑门灯改变状态不满足逻辑门打开条件,逻辑门不会再次发出信号但是会关闭)。

故障逻辑门灯[编辑 | 编辑源代码]

在逻辑门上方放置故障灯会使其变蓝,并完全改变其逻辑行为。若逻辑门被讯号触发,它会随机选择其下方的逻辑灯,若选中的灯是亮的,逻辑门便会发出一次讯号。所以假设其下有三个灯,两个暗的、一个亮的,则逻辑门收到讯号时会有1/3的机会发出讯号。放了故障灯后,逻辑门上的其它灯将无法影响逻辑门。

故障灯可以在同一个时刻被多次触发,导致逻辑门有更高的机率发出讯号。但同时刻一样只能发出一次讯号。比如:

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逻辑门,有的话理论上它会在每次输入改变时都送出一次讯号。
  • 多个故障灯可以连接在一个逻辑门上,且都可用来控制逻辑门。不过只有逻辑门底下的灯才可以控制发射讯号的机率。

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