Skip to content

Timing

When creating automation scripts, you often need to wait for a train to arrive at a certain position or to let it drive for a specific amount of time. Model Train Script provides actions for both.

Wait

Pauses script execution for a configured amount of time.

SettingDescription
TimeThe wait duration in seconds.
RandomWhen enabled, the actual wait time is randomly chosen between a minimum and maximum value. This adds variation to your scripts — for example, random station dwell times.
Minimum timeThe shortest possible wait duration (only available when random is enabled).

WARNING

While this action is sometimes necessary, try to minimise its use and rely on sensors instead. Due to the mechanical nature of model trains, you cannot guarantee the precise position of a train after a timed wait. Use "wait for condition" whenever possible.

Wait for condition

Pauses execution until a specified condition on your layout becomes true. This is the most reliable way to synchronise your script with the physical state of the layout.

SettingDescription
ConditionThe condition to wait for. Can be based on accessories, feedback sensors, vehicle state, flags, variables, or camera detection.
TimeoutOptional confirmation time in milliseconds. When set, the condition must remain true for this duration. If the condition goes false during the timeout, the action resets and waits again.

The condition is evaluated in an event-driven way — it does not poll. As soon as the layout state changes, the condition is re-evaluated.

INFO

The timeout setting is useful for filtering transient sensor readings. For example, if a feedback sensor briefly activates due to electrical noise, the timeout ensures the action only continues when the sensor stays active for the configured duration.

Condition types

Conditions used in "wait for condition" — and also in section and action execute conditions — can be based on:

TypeDescription
AccessoryAn accessory matches a specific state (e.g., a turnout is thrown).
Feedback sensorA sensor is active or inactive, optionally occupied by a specific vehicle or the selected vehicle.
VehicleA vehicle's speed, direction, function state, or profile matches an expected value.
FlagA flag is enabled or disabled.
VariableA variable equals a specific value.
CameraA camera detects a vehicle at a specific detection point.

All condition types support negation — you can check that a condition is not true.