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.
The Script Editor
can be used for objects which can execute Lua scripts or contain Lua libraries.
To open the Script Editor
you have to find the Lua Script Body property in the Properties Panel.
Depending on the classes, the Lua Script Body property can be found in different sections of the Properties Panel.
For some (like Core and Connector objects) this property is located in the Script Library compound while for others (e.g. ActionItem) it is in the Common section. For Generic Items, you first have to set Generation Type in the section with the same name to 'Lua Script Data Generator' to reveal the Lua Script Body property in this section. While this may sound confusing in this general explanation, the different locations are the result of the different object types being specifically designed for specific tasks.
Once you have located the Lua Script Body property for your object, click on the … icon in that line to open the 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.

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:
Element | Shortcut | Action |
---|---|---|
Ctrl+Shift+S |
Save the contents of the Input Pane as a (.lua-)file |
|
Ctrl+Shift+O |
Load a (.lua-)file into the Script Editor |
|
Ctrl+X |
Cut the selected part from the Input Pane to the Clipboard |
|
Ctrl+C |
Copy the selected part from the Input Pane to the Clipboard |
|
Ctrl+V |
Paste the contents of the Clipboard into the Input Pane at the position of the cursor. |
|
Open the Search Dialog |
||
Open the Replace Dialog |
||
Ctrl+Z |
Undo your latest edit |
|
Ctrl+Y |
Undo your latest 'Undo' |
|
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. |
||
Comment out the selected lines |
||
Uncomment the selected lines |
||
Switch Output pane invisible / visible |
||
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 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.
