BETA — Preview build
Skip to content
Run another script from here

Execute script ​

Runs another script as part of the current one, like calling a subroutine. When the other script is done, the current script continues with its next action.

Settings ​

SettingDescription
InputSpecific runs one script you pick. Random picks a script with a certain tag.
ScriptOnly for Specific: the script to run.
TagOnly for Random: the tag. One of the available scripts with this tag is picked at random each time the action runs.
Wait availableWhen on and no script is available, the action waits until one becomes available instead of skipping it.

How it works ​

  • The other script runs inside the current script and shares its context: the selected vehicle, active flags, stored vehicle state, and held clearance. Changes it makes, such as selecting another vehicle, are still in effect afterwards.
  • A script is only available when it is not disabled and its execute conditions are met. This applies to a specific script as well as to scripts picked by tag.
  • When no script is available and Wait available is off, the action is skipped. With Wait available on, the action checks again every time something changes on the layout.
  • The repeat setting of the other script is respected: a repeating script keeps running until its repeat condition is no longer met.

TIP

Random scripts by tag are an easy way to add variety. Tag several station arrival scripts with "station-arrival" and pick one at random each time a train arrives: one plays an announcement, another rings a bell, a third does nothing at all.

Example ​

Many of your scripts end with the same steps: stop the train, turn off the lights, and release the clearance. Put those steps in a script "Park train" and end the other scripts with Execute script "Park train". When you want to change how trains are parked, you change it in one place.