TrainCarts/控制牌/语句

From BergerHealer Wiki
Revision as of 16:31, 5 September 2024 by Halogly (talk | contribs)
Jump to navigation Jump to search
Other languages:
English • ‎中文(中国大陆)‎

介绍

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

使用示例

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

移除空矿车

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

列车存有物品时启动列车

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

向特定玩家发车

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

语法

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

Most statements also support operators. Operators are:

  • = equals
  • != not equals
  • >= greater or equal than
  • <= smaller or equal than
  • > greater than
  • < smaller than

To use an operator, append it after the statement. For example, minecarts>=5 will check if there are more than 5 minecarts in the train. trainsize>=5 also counts storage and powered minecarts. You can even use it in arrays. Using i@stone=64 you can check if there are exactly 64 stone in the train. All statements that can be interpreted as an amount have operator support, including counting the amount of mobs in the train: m@cow>5. If no operator is given the default operator >0 is used, or in the case of items, the amount that is specified in front of the item name.

Statement Meaning
passenger The train has a passenger
items The train contains a chest and has items
empty The train has no passenger and no items
fuel The train contains a furnace which has fuel
trainsize The train cart count matches (e.g.: trainsize>=3)
chest_minecart The train has a number of chest minecarts (e.g.: chest_minecart>=1). Also works for hoppers/powered/etc. types.
velocity
speed
The train velocity (movement speed) can be evaluated, or gets if the train is moving
powered The train contains a powered minecart
storage The train contains a storage minecart
minecart The train contains a regular minecart
redstone The sign is powered by redstone
maxspeed Evaluate the maximum speed set
mobenter Checks the mob enter property
playerenter Checks the player enter property
playerexit Checks the player exit property
destination Checks if a destination is set on the train
random Has a 50% chance of turning on
n@<names>
name@<names>
The train name equals one of the names specified
i@<items> The train contains one of the items specified
o@<owner> The train contains this owner
d@<destination> One cart in the train has this destination set
p@<player> The train is occupied by this player
m@<mobnames> The train is occupied by one of these mobs
pi@<items> One of the players has one of the items in his inventory
ph@<items> One of the players has one of the items in his hand
ed@<directions> The minecart is moving into a given direction (switcher: upon entering the sign)
rs@<directions> The sign is powered from one of the directions specified
[email protected] Has a 30% chance of turning on (instead of the default 50%) (1.0 is equivalent to 100%)
anything
t@<tags>
For anything else the plugin checks if the train has it set as a tag

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*