Event management with Lua

Lua is a scripting language which is integrated into 3D Train Studio to facilitate control of the layout. It does not require a separate download or install.

The graphical event management dialogs allow no-code actions and conditions to be set for most requirements for the automation of layouts. However, there are situations where more control is required in managing events, and for these, Lua can be used.

Lua allows the train master to:

  • Create any event.
  • Click on under “Which actions should be performed?” to open the script editor.

Instead of the action list, a text window is now displayed in which you can enter the Lua commands. Tip: An existing action list is automatically converted to Lua when you switch to the script view. You can use this conversion as an introduction to programming with Lua.

Actions and Conditions

Lua scripts can be mixed with the predefined actions and conditions as desired, ie. an event can be composed of predefined actions and conditions as well as Lua scripts:

  • Click in the Action List, then click Actions > Run Script to add a script to a list of existing actions.
  • Click and then click Conditions > Script Condition to program a single condition with Lua. The Lua script must return a Boolean to decide whether the condition applies (true) or not (false).

Module scripts

Different events often use common data and functions. In order to store these in a central location, a script can be defined in an event module. To do this, click on the symbol in event management and select Script.

Each event module has its own script, whereby all the variables and functions defined there are available throughout event management.


All commands supported by 3D Train Studio are documented in the automatic help (auto-completion). In addition, the following information can help with further questions and problems: