TrainCarts/控制牌/语句

From BergerHealer Wiki
Revision as of 18:01, 5 September 2024 by Halogly (talk | contribs) (Created page with "{| class="wikitable" |- ! 语句 ! 释义 |- | passenger | 列车上有乘客。 |- | items | 列车上有箱子,且装有物品。 |- | empty | 列车上没有乘客和物...")
Jump to navigation Jump to search
Other languages:
English • ‎中文(中国大陆)‎

介绍

switcher 转辙器detector 侦测器skip 跳过控制牌都可使用语句条件判断来切换轨道、切换拉杆或执行其他类型的操作。语句通常用在控制牌的第三行和第四行。你还可以在控制牌下方继续添加其他控制牌,来扩展更多语句。

使用示例

对于管理世界的列车路线,你一定得试试路线查找。如果你需要根据某些属性对矿车进行分类,并有条件地激活某些控制牌或以某种方式发车,那么你需要使用语句。以下是一些示例。

移除空矿车

如果矿车上没有乘客,则启用摧毁器。

列车存有物品时启动列车

列车存有物品时启用车站。

向特定玩家发车

如果列车的车主是某个指定的玩家,则切换轨道通向该玩家。

语法

你可以在语句前面输入“!”来表示否定。如果控制牌第一行设置为 [cart],则会将列车看作一辆辆矿车。数组语句格式为 name@<数组>,可以对多个属性进行操作。例如,i@wood 操作列车中的物品,并检测其中是否是木头。对于多个物品,需使用(;)分隔,例如 ed@north;south 仅匹配向北或向南行驶的列车。

大多数语句支持运算符。运算符包括:

  • = 等于
  • != 不等于
  • >= 大于等于
  • <= 小于等于
  • > 大于
  • < 小于

运算符需要输入在语句的后面。比如,minecarts>=5 将检测列车中是否有超过 5 辆矿车。trainsize>=5 还计算运输矿车和动力矿车。你还可以将其组成数组。使用 i@stone=64 可以检测列车中是否正好有 1 组石头。所有可以解析为数量的语句都支持运算符,包括计算列车中的生物数量:m@cow>5。如果没有指定运算符,则使用默认运算符 >0,或者在物品的情况下,使用物品名称前面指定的数量。

语句 释义
passenger 列车上有乘客。
items 列车上有箱子,且装有物品。
empty 列车上没有乘客和物品。
fuel 列车上有个装有燃料的熔炉。
trainsize 列车车厢数量匹配(例如:trainsize>=3)。
chest_minecart 列车有一定数量的运输矿车(例如:chest_minecart>=1),这也适用于漏斗/动力矿车等类型。
velocity
speed
检测列车速度(移动速度),或者判断列车是否正在移动。
powered 列车包含动力矿车。
storage 列车包含储存矿车。
minecart 列车包含普通矿车。
redstone 控制牌被红石激活时触发。
maxspeed 检测最大速度。
mobenter 检测生物进入属性。
playerenter 检测玩家进入属性。
playerexit 检测玩家离开属性。
destination 检测列车是否设置了目的地。
random 有 50% 几率启用。
n@<名称>
name@<名称>
列车名称等于以下指定名称之一。
i@<物品> 列车载有以下物品之一。
o@<车主> 列车包含以下车主之一。
d@<目的地> 列车中有一辆矿车设置了这个目的地。
p@<玩家> 列车被以下玩家之一占用。
m@<生物名称> 列车被以下生物之一占用。
pi@<物品> 其中一名玩家的背包中有以下物品之一。
ph@<物品> 其中一名玩家的手上有以下物品之一。
ed@<方向> 矿车正在向指定的方向之一移动(转辙器:进入时)。
rs@<方向> 控制牌由以下指定的方向之一激活。
[email protected] 有 30% 的几率启用(而不是默认的 50%;1.0 相当于 100%)。
anything
t@<标签>
对于任何其他事情,插件都会检测列车是否将其设置为标签。

And logic

Since everything is evaluated as an OR, how can you check if the train has two of the same? The easiest method is to invert two statements, toggling a lever which powers an inverted sign. For example:

Signtemplate.png
[cart]
switcher
!o@me
!a
Signtemplate.png
[!cart]
chest in
If not owned by 'me' or not has tag 'a' then not transfer items
If owned by 'me' and has tag 'a' transfer items

If this proves too hard to do (you need to evaluate more than 3 statements), you will have to use a redstone circuit and multiple switcher signs instead.


Tags

For all statements other than in the syntax table above, the name is compared to tags on the train. To find the tags, you can use wildcards to check for multiple tags at once:

 * - has a tag
 !* - has no tags
 *a - has a tag ending with 'a'
 a* - has a tag starting with 'a'
 *a* - has a tag containing 'a'
 *ab*cd* - has a tag containing both 'ab' and 'cd'

For example, the following sign uses tags to switch tracks. If the train contains a tag starting with station it goes left, if it contains a tag containing main it will go right. If it contains both, it will go straight ahead.

Signtemplate.png
[!train]
switcher
station*
*main*