Text Controller
Use the Text Controller component to easily declare one or more custom controls and then build the Lua script associated with those controls using a Lua text editor.
Note: This component uses the Q-SYS Scripting Engine, which is a licensed feature on certain Cores manufactured with Q-SYS 7.0 and later. For more information, see Licensing.
- In your schematic, double-click the Text Controller component to open the elements editor.
- In the Controls section, click to add a new control.
- In the Properties section, configure the new control. See Properties.
- Click Edit to open the Lua text editor.
- Write Lua code for your defined controls. Click Save changes (yellow bar) to save your script.
- Run (F5) or emulate (F6) your design to start the script.
To see an example configuration, see Example.
Double-click the Text controller component to open the elements editor, which is where you define controls for your Lua script. After defining controls, click Edit to open the Lua text editor.
Controls
Control |
Function |
---|---|
Controls |
|
Serial Port Inputs |
Specify how many serial port input pins to expose, from 0 to 128. Use these pins with the SerialPorts Lua library. |
Virtual Serial Port Outputs |
Specify how many virtual serial port output pins to expose, from 0 to 128. Use these pins with the SerialServerPorts Lua library. |
Properties
Property |
Function |
Choices |
---|---|---|
General |
||
Name |
Specify a name for the input. |
Text input |
Count |
Specify the number of controls of the specified type to create. |
1 to 256 |
Control Type |
||
Category |
Button
Select a Push Action:
Knob
Specify a Max Value and Min Value for the specified Units:
Indicator
Specify a Type: LED, Meter, Text, Status. Text
Specify a Type: Text Box, Combo Box, List Box |
Button, Knob, Indicator, Text |
Control Pin |
Expose pins for these controls: None, Input (pins on the left), Output (pins on the right), or Both. |
None, Input, Output, Both |
Tip: While in the Script area, press F1 for help on the Lua scripting language.
The script editor contains these areas:
- Text editor – Write script for your configuration. You can edit the script in the Design, Emulate, or Run modes, but any errors are only detected in the Run or Emulate modes.
- Script menu – Click to start or stop the script.
- Information bar at the top of the script – Click the yellow "Save changes" bar to reload (not run) the script. Syntax errors are indicated in a red bar at top-right, as well as in the Debug Output area.
- Search bar – Click the Search bar on the right side of the page to locate or replace text in your script. As a shortcut, press F3 to find the next item.
Rules for Referencing Control Names in Script
- Control names that contain no spaces can be referenced with dotted notation. Examples: 'Button' could be referenced 'Controls.Button.Boolean'; Names with spaces: 'Big Button' = 'Controls["Big Button"].Boolean'
- For a single control (Count = 1), you can directly access the control. Example: 'MyKnob' =
'Controls.MyKnob.Value'
- If at least two controls are defined in a row (Count = 2+), you must access the controls as an array. Example: 'MyKnobs' x 3 =
'Controls.MyKnobs[1].Value', 'Controls.MyKnobs[2].Value', 'Controls.MyKnob[3].Value'
- If at least two controls are defined in a row (Count = 2+) and spaces are used in the control name, quotes must be used around the control name. Example: 'My Knobs' x 2 =
'Controls["My Knobs"][1].Value', 'Controls["My Knobs"][2].Value'
See Debug Output.
The available Control Pins depend on settings in Properties.
Pin Name |
Value |
String |
Position |
Pins Available |
---|---|---|---|---|
Code |
(text) |
Input / Output |
||
Script Start |
(trigger) |
Input / Output |
||
Script Status |
(text) |
Output |
||
Script Stop |
(trigger) |
Input / Output |
In this simple example, Text Controller is configured with a control button that can be used to retrieve a list of control names from any named component in the design.
Naming components
This example contains two audio components - Gain and Delay. Rename each with a custom name ("MyGain", "MyDelay"). Renaming the components with custom names allows the Named Components function to retrieve a table of control names for those components. For more information about named components in Lua, see Component.
Defining controls
Drag Text Controller onto the canvas and double-click it to open the elements editor. Add three controls with these names and properties:
- Get Controls – A trigger button that retrieves a table of control names for the specified component custom name. (Category = Button; Push Action = Trigger)
- Component Name – A text box for entering the custom name of a component. (Category = Text; Type = Text Box)
- Output – A text box to contain the returned table of control names. (Category = Text; Type = Text Box)
Adding Lua script
Click Edit to open the Lua text editor. Add the following script, and then click Save changes.
Controls["Component Name"].EventHandler = function(ctl) comp = Component.New(ctl.String) end -- Returns all controls of the component in "Component Name" Controls["Get Controls"].EventHandler = function() local str = " Get Controls for "..Controls["Component Name"].String.."\r" for k,v in pairs(comp) do str = str..k.."\r" end Controls.Output.String = str end comp = Component.New(Controls["Component Name"].String)
Running the script
- Emulate (F6) or run (F5) the design to start the script.
- Click the schematic page tab ("Page 1" if you didn't rename it).
- In the Component Name text box, type the name of one of the custom control names - MyGain - and then press Enter.
- Click Get Controls.
- The Output text box shows the list of controls for that component name. Repeat the process for MyDelay to see how the output changes.
- Refer to Control Scripting and the Lua 5.3 Reference Manual for information about writing scripts.
- Q-SYS Training - Control 101
Learn the basic Q-SYS third party control principles, including Lua scripting basics.