Table of Contents

TrainCarts Commands Selectors

This page contains information about using selectors with TrainCarts commands to target specific trains or passengers of trains.

Introduction

TrainCarts adds command selectors similar to Minecraft's @e selector. These selectors allow targeting based on various train properties. Two selectors exist: `@train` and `@ptrain`. Use `/train info –train @ptrain[` to see available conditions in-game.

### Quick Command Examples

Example Description
———————-
`/say hello @ptrain[distance=..5]` Message “hello” to passengers of trains within 5 blocks
`/kick @ptrain[name=train23]` Kick players in train named 'train23'
`/train destroy –train @train[destination=InterState5]` Destroy trains heading for InterState5
`/train eject –train @train[dx=-2..2,dy=-3..3,dz=-2..2]` Eject trains within a specified cuboid range
`/train launch 0.5 –options 2 –train @train[tag=express]` Launch trains tagged 'express' to a speed of 0.5 over 2 blocks

Conditions

Multiple conditions can be combined using commas, and all number-based conditions support Minecraft range syntax (e.g., `a..b`, `..6`, `12..`). Prefixing a value with `!` negates the condition.

### Position Cuboid Specify coordinates and optionally grow the cuboid using `dx/dy/dz`. The `world` condition can target trains in specific worlds.

Examples:

### Distance Filter trains based on spherical distance to the sender or specified cuboid.

Examples:

### Sort and Limit Sort results by `nearest`, `furthest`, or `random`. Use `limit` to specify the number of results.

Examples:

### Train Name Select trains by name or pattern. Supports wildcards.

Examples:

### Train Tags Filter trains by tags. Supports multiple tags and wildcards.

Examples:

### Passenger Count Filter trains based on the number of passengers or player passengers.

Examples:

### Derailed Select derailed trains.

Examples:

### Unloaded Select trains in unloaded chunks.

Examples:

### Speed Filter trains by speed.

Examples:

### Miscellaneous Properties Additional properties can filter selections:

For more details, visit the [original page](https://wiki.traincarts.net/p/TrainCarts/Commands/Selectors).