Script Editor

While the Console Display allows you to execute Lua scripts immediately within the system, the Script editor is used for writing Lua scripts, which you itend to be part of the functionality of an object.

This functionality can either be the script itself or it can be providing a functions library for subordinate objects.

To open the Script Editor for an Object which can execute Lua scripts (like ActionItem or Generic Item), select the object in the Model Panel and in the Properties Panel unfold the Common section and then click on the '…​' icon in the Lua Script Body line. This opens a new Script Editor Window.

Most objects on a higher hierarchical level in the model can provide Script Libraries for subordinate objects. For more information on Script Libraries and how to add them to the system, see Mangaging Script Libraries.

Console Display
Figure 1. The Script Editor

The Script Editor is made up of 4 parts:

  • Menu Bar

  • Input Pane

  • Output Pane

  • Status Bar

The Menu Bar

In the Menu Bar you find the following icons:

Table 1. Script Editor - Menu Bar Options
Element Shortcut Action

icon save

Ctrl+Shift+S

Save the contents of the Input Pane as a (.lua-)file

icon open

Ctrl+Shift+O

Load a (.lua-)file into the Script Editor

icon mass config cut

Ctrl+X

Cut the selected part from the Input Pane to the Clipboard

icon mass config copy

Ctrl+C

Copy the selected part from the Input Pane to the Clipboard

icon mass config paste

Ctrl+V

Paste the contents of the Clipboard into the Input Pane at the position of the cursor.

icon mass config magnifier

Open the Search Dialog

icon mass config replace

Open the Replace Dialog

icon backward

Ctrl+Z

Undo your latest edit

icon forward

Ctrl+Y

Undo your latest 'Undo'

icon lua intellisense enable

Switch the LuaSense helper tool on / off

LuaSense provides suggestions based on the code being entered and displays information for functions including the necessary parameters and code examples.

icon lua comment

Comment out the selected lines

icon lua uncomment

Uncomment the selected lines

icon glasses

Switch Output pane invisible / visible

icon play

F5

You can only 'run' scripts which belong to objects and are executable (no library). Running a script automatically applies the latest version of the script the Script Property of the Object.

The Input Pane

In the Input Pane of the Script Editor the Lua code can be entered. The Script Editor provides Syntax Highlighting and with Lua Sense enabled, it offers suggestions for code completion. To execute the code entered in the Input pane press "Execute" icon in the Menu Bar or F5.

The Output Pane

The results of the execution of a script are displayed in the output pane. The first element is a dot, which is green if the script finished successfully. In case of an error in the script, this dot turns red. The next item is the name of the Object, to which the script belongs. The last item in the output pane is the Value which is returned by a successfully executed script or an error message, specifying the location of the error in the script and the error type.

The Output Pane
Figure 2. The Output Pane

The Status Bar

On the right side of the statusbar the current position of the cursor shown by line ('Ln') and column ('Col'). Modifications of the script since its last execution are indicated by the word 'Modified', written in yellow, on the left side of the status bar.

The 'OK' button applies the current state of the script to the Script Property. The 'Cancel' button tries to close the Script Editor, asking for confirmation.

The Statusbar of a Script Editor window
Figure 3. The Statusbar of a Script Editor window