beautypg.com

Lua scripts, Lua script editor, Debugging lua scripts – ETC Unison Mosaic Designer v1.11.0 User Manual

Page 207: Lua script, Script

background image

Lua scripts

Lua scripts

We use a scripting language called Lua, which has been extended to provide functionality specific to the Unison
Mosaic Controllers. Tutorials and reference manuals for the Lua language can be found at

www.lua.org

. We will

not attempt to document the Lua language here, but just the Unison Mosaic specific extensions. Please contact

support

if you need assistance with preparing a script or if you would like some examples as a starting point.

Lua script editor

The Lua Script Editor allows you to edit scripts from Triggers Conditions and Actions, and Custom presets within
Designer. The Script Editor is launched by pressing the Launch Editor button in the trigger properties:

The main area of the editor is the code editor where you enter the source code of the script. The code editor will
colour the Lua syntax to aid readability. Standard clipboards shortcuts and undo/redo are supported.

To import a Lua script from an external file, use File > Import (Ctrl+I).

To save a Lua script to a file, use File > Export (Ctrl+E).

To compile the script and check for syntax errors, use Build > Build (F7). If there are errors in the script, they will
be displayed at the bottom of the window.

When you have finished editing the script, press Ok to close the Script Editor. If there are still errors in your script,
you will be prompted whether the invalid source should be saved or not.

To discard any changes close the Script Editor and select Discard from the confirmation dialog.

Debugging Lua scripts

If your script contains no errors, use Debug > Run (F5) to execute it in a debugger. This will run the script and
report any runtime errors in the Output tab below the source editor. Note that only Custom preset scripts can be
executed in the debugger.

If there are errors, you can place breakpoints in the source to force the debugger to halt execution at that point and
allow you to examine the state of variables and execute further instructions one at a time.

- 207 -