Lua Script

The Lua Script module allows you to create and manage your own scripts.

In the following sections, the basic concepts and procedures are described. For more detailed information on all parameters, editing possibilities, advanced features, etc., refer to the online documentation that can be found under http://developer.steinberg.help.

Internal Editor vs. External Editor

The Lua Script MIDI module comes with an internal, plain text editor. This editor can be used to write, load, and edit scripts. However, it does not offer code highlighting or advanced editing features.

If you want to write complex scripts, you can use an external editor. However, scripts that are written in an external editor are not part of the script module. Only the file path for the script is saved in the VST Preset.

Scripts that are written in the internal editor have the following advantages and disadvantages:

  • You can easily use them on another computer, because they are part of the Lua Script module.

  • If an internal script is modified, this modification is not automatically applied to all presets in which the script is used. It has to be added manually to each preset.

Scripts that are written in an external editor have the following advantages and disadvantages:

  • They can be easily modified throughout all presets that use them.

  • If you want to use them on another computer, you must either make sure that the corresponding script file is available on this computer, together with the script module, or you have to manually copy the source code into the internal script editor.

Toolbar

Load Script

Allows you to load a script from disk.

The loaded file is referenced by the script module.

Save Script

Scripts that are created with the internal editor can be saved to disk.

After saving the script to disk, it is referenced by the Lua Script module.

New Script

Clears the current script module. This command removes any internal or referenced script.

Edit Script

Opens the script editor.

  • If an external editor is specified in the Options Editor, this editor is used.

  • If no external editor is specified, the internal editor is used.

Script Source File

Shows the file path to the script source file on your disk.

Reload from File/Script

Allows you to reload the script.

Note
  • This function does not clear any output messages or remove any parameters that are defined for the script module.

Reset from File/Script

Resets the current script.

Note
  • This function removes any existing output messages, as well as parameters that are defined for the script module.

Connect to Debugger

Connects the script module to an external debugger.

Syntax/Runtime Error

If a syntax or runtime error occurs when processing the script, this indicator lights up. In this case, you must fix the error and reset the script.

Output Messages

In this section, any syntax and execution errors or the output of the print function are displayed.

  • To show/hide this section, click Show/Hide Output Messages in the top right corner of the editor.

Max Lines

Sets the maximum number of visible lines.

Copy Messages to Clipboard

Copies the output messages to the clipboard. This allows you to copy larger output messages to an external editor that offers a text search, for example.

Note

This also includes any older messages that are not visible anymore.

Clear Message Display

Clears the output messages.

Library Path

Lua's require function allows you to load and run your own libraries. In the Library Path field, you specify where require searches for libraries.

Note

The path that you specify here only applies to this script module. The global library path for script modules is specified in the Options Editor.

Dependent Files

This section lists all files that are required by the script module. This list is used to add the script files to a VST Sound container, for example.

  • To show/hide this section, click Show Dependent Files in the top right corner of the editor.

Add Required Files Automatically

Activate this button to automatically add the files that you included using the require function to the list of dependent files.

Clear Dependent Files

Removes all entries from the list of dependent files.

Select File

Allows you to change the current entry or to add a new file.

Select Folder

Allows you to add all files in the specified folder to the list of dependent files.

Delete Entry

Removes the selected entry from the list of dependent files.