Difference between revisions of "TrainCarts/Commands/Selectors/zh-cn"
(Created page with "<code>x/y/z</code>条件指定了世界上要选择列车的位置,其指定的是一个长方体区域。也可以指定<code>dx/dy/dz</code>来增大长方体。如果仅...") |
(Created page with "{| class="wikitable" |- | @train[x=10..12,y=23..56,z=-100..-80] | 选择所有在(10, 23, -100)->(12, 56, 80)内部的列车。 |- | @train[x=10,y=23,z=-100,dx=2,dy=33...") |
||
Line 44: | Line 44: | ||
<code>x/y/z</code>条件指定了世界上要选择列车的位置,其指定的是一个长方体区域。也可以指定<code>dx/dy/dz</code>来增大长方体。如果仅指定 dx/dy/dz,则使用命令执行者的 x/y/z 坐标。可以使用<code>world</code>条件来在特定世界上运行,或从无法推断世界的服务器控制台运行。 | <code>x/y/z</code>条件指定了世界上要选择列车的位置,其指定的是一个长方体区域。也可以指定<code>dx/dy/dz</code>来增大长方体。如果仅指定 dx/dy/dz,则使用命令执行者的 x/y/z 坐标。可以使用<code>world</code>条件来在特定世界上运行,或从无法推断世界的服务器控制台运行。 | ||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| @train[x=10..12,y=23..56,z=-100..-80] | | @train[x=10..12,y=23..56,z=-100..-80] | ||
− | | | + | | 选择所有在(10, 23, -100)->(12, 56, 80)内部的列车。 |
|- | |- | ||
| @train[x=10,y=23,z=-100,dx=2,dy=33,dz=20] | | @train[x=10,y=23,z=-100,dx=2,dy=33,dz=20] | ||
− | | | + | | 同上,但使用 dx/dy/dz 指定“增大”的长方体。 |
|- | |- | ||
| @train[x=10,y=10,z=10,dx=-2..2,dy=-10..10,dz=-2..2] | | @train[x=10,y=10,z=10,dx=-2..2,dy=-10..10,dz=-2..2] | ||
− | | | + | | 复杂使用:从点(10, 10, 10)开始在 y 和 z 两个方向上扩大长方体。将长方体变为(8, 0, 8)->(12, 20, 12)。 |
|- | |- | ||
| @train[dx=-10..10,dy=-5..5,dz=-10..10] | | @train[dx=-10..10,dy=-5..5,dz=-10..10] | ||
− | | | + | | 在命令执行者(命令方块 / 玩家)周围选择的长方体。 |
|- | |- | ||
| @train[world=world_the_end,x=10,y=89,z=-20,dx=-10..10,dy=-10..10,dz=-10..10] | | @train[world=world_the_end,x=10,y=89,z=-20,dx=-10..10,dy=-10..10,dz=-10..10] | ||
− | | | + | | 指定世界名称可用于定位其他世界的列车。 |
|} | |} | ||
− | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> |
Revision as of 01:13, 26 September 2024
介绍
TC 添加了命令选择器,用于定位列车或列车上的乘客,类似于 Minecraft 的目标选择器。除了基于类型的选择器外,其他 train 属性也可以用来筛选符合特定条件的列车。这些选择器可以与其他插件一起使用。如果要选择多个玩家或列车为目标,则命令会为每个玩家或列车重复执行。
存在两个选择器:@train
和@ptrain
。两者都接受相同的选择器条件,这将在本页的其余部分讨论。
要快速预览游戏中可用的条件,请使用/train info --train @ptrain[
等 TC 命令,该命令会显示支持的条件。
快速命令示例
实例 | 描述 |
---|---|
/say hello @ptrain[distance=..5] | 向 5 格方块距离内的列车上的乘客发送 "hello"。 |
/kick @ptrain[name=train23] | 踢出名为“train23”的列车上的乘客。 |
/train destroy --train @train[destination=InterState5] | 销毁目的地为“InterState5”的列车。 |
/train eject --train @train[dx=-2..2,dy=-3..3,dz=-2..2] | 在以命令执行者为中心设置的长方体范围内弹出列车。 |
/train launch 0.5 --options 2 --train @train[tag=express] | 将带有“express”标签的列车以 0.5 的速度启动到 2 格方块以外的距离。 |
条件
可以指定多个条件,之间为逻辑与。所有基于数值的条件都支持 Minecraft 范围语法:a..b
。例如,-5..5
(-5 到 5),..6
(6 或 更小)和12..
(12 或 更大)。在条件前面加上!
会使条件反转检测,检测某条件是否“不”。
在下面的所有示例中,若要针对列车上的乘客,可以将@train
替换为@ptrain
。
坐标长方体
x/y/z
条件指定了世界上要选择列车的位置,其指定的是一个长方体区域。也可以指定dx/dy/dz
来增大长方体。如果仅指定 dx/dy/dz,则使用命令执行者的 x/y/z 坐标。可以使用world
条件来在特定世界上运行,或从无法推断世界的服务器控制台运行。
@train[x=10..12,y=23..56,z=-100..-80] | 选择所有在(10, 23, -100)->(12, 56, 80)内部的列车。 |
@train[x=10,y=23,z=-100,dx=2,dy=33,dz=20] | 同上,但使用 dx/dy/dz 指定“增大”的长方体。 |
@train[x=10,y=10,z=10,dx=-2..2,dy=-10..10,dz=-2..2] | 复杂使用:从点(10, 10, 10)开始在 y 和 z 两个方向上扩大长方体。将长方体变为(8, 0, 8)->(12, 20, 12)。 |
@train[dx=-10..10,dy=-5..5,dz=-10..10] | 在命令执行者(命令方块 / 玩家)周围选择的长方体。 |
@train[world=world_the_end,x=10,y=89,z=-20,dx=-10..10,dy=-10..10,dz=-10..10] | 指定世界名称可用于定位其他世界的列车。 |
Distance
The distance
condition filters trains based on distance to the sender, or a cuboid specified. This is a spherical distance.
@train[distance=..10] | All trains 10 blocks or less away from the sender |
@train[distance=1000..] | All trains 1000 blocks away or more from the sender |
@train[x=100,y=50,z=-100,distance=..5] | All trains 5 blocks or less away from coordinate (100, 50, -100) |
@train[x=10,y=10,z=10,dx=50,dz=50,distance=..10] | All trains 10 blocks or less away from cuboid (10, 10, 10) -> (60, 10, 60) |
Sort and Limit
The sort
and limit
conditions can be used to pick a single result from many based on distance, or to pick limited results at random. Sort supports conditions nearest
, furthest
and random
. Limit must be a natural integer.
@train[distance=..100,sort=random,limit=1] | Picks a single random train 100 blocks away or less |
@train[distance=..100,sort=nearest,limit=2] | Picks at most 2 nearest trains, 100 blocks away or less |
@train[distance=1000..,sort=furthest,limit=10] | Picks at most 10 trains furthest away, 1000 blocks distance away or more |
Train Name
The name
condition can be used to select trains by name, or a name pattern. Supports the same wildcard pattern rules as the remote control syntax.
@train[name=train12] | Selects train with name 'train12' |
@train[name=Intercity*Express] | Selects trains with name starting with "Intercity" and ending with "Express" |
@train[name=*] | Selects all trains on the world |
Train Tags
The tag
condition, which can be specified multiple times, can be used to select the tags assigned to trains and filter on those. Like the name condition, this supports a wildcard pattern. This only checks that a particular tag is or isn't present, not that it is the only tag present.
@train[tag=mytag] | Selects trains that have tag 'mytag' |
@train[tag=*fast,tag=!express] | Selects trains that have a tag ending with 'fast', but do not have tag 'express' |
Passenger Count
The passengers
and playerpassengers
conditions select the trains that meet a certain number of (player) passengers. This supports the range command to check for 'at least' a number of passengers, such as @train[passengers=5..]
Derailed
The derailed
condition selects trains that have derailed. For example: @train[derailed=1]
or @train[derailed=true]
Unloaded
The unloaded
condition selects trains that are inside unloaded chunks and are therefore no longer simulated. Example: @train[unloaded=1]
or @train[unloaded=true]
.
Trains that keep chunks loaded do not unload.
Speed
The speed
condition (alias: velocity
) selects trains that move at a certain speed. This is the actual movement speed, which is at most the speed limit set for the train. Example: @train[speed=0]
for trains that are not moving.
Miscellaneous Properties
More might be added in the future, but the additional properties can be used to filter the selection
destination | Destination set for the train |
friction | Friction modifier of the train (default: 1) |
gravity | Gravity modifier of the train (default: 1) |
keepchunksloaded | Whether the train keeps nearby chunks loaded |
speedlimit | Speed limit set for the train |
ticket | Same checks as for tags, but for ticket names instead |