Auto switch turnout
This example demonstrates a self-resetting turnout, inspired by the automatically switching turnouts (Rückfallweiche) of the HSB narrow-gauge railway in the Harz mountains, Germany.
Concept
The turnout has a fixed default position. When a train approaches from the diverging side, the turnout switches direction. Once the train has passed, the turnout automatically resets to its default position after a delay. While resetting, the signal warns other trains not to enter since the turnout state may change.
Script features
- Sensor trigger — The script is triggered when a sensor detects the turnout is in a non-default state.
- Signal protection — The signal switches to a warning state during the reset period and back to proceed afterwards.
- Retry mechanism — If the turnout does not return to its default state (e.g. because a train is still on it), the script retries automatically.
- Manual override — Conditional sections prevent the auto-reset from executing when the turnout was switched manually.

