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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
- 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 Text Controller.
- 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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Inputs and Outputs
Control components do not have traditional input and output pins. If a Control Pin is available for the component, an input or output will appear.
Control Pins represent the controls available in the component's Control Panel. Control Pins are used to link controls between Schematic Elements, and link to / from Control Scripts. Control Pin signal pins are represented by a square, and the wiring is represented by a thick blue / white line.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Text Controller Properties
This component has no configurable properties.
Graphic Properties
Label
Use the Label property to change the name of the component in the schematic. The Label property defaults to the component name. To learn more about renaming schematic elements, see Organizing Your Design.
Position
The coordinates reference a specific place in the schematic - for example,"100,100" (horizontal, vertical). 0,0 is the upper left corner of the schematic.
Fill
Sets the fill color of the component in the schematic.
Script Access Properties
Code Name
Displays the currently assign name for control access. You can use the auto-assigned name or customize it. Q-SYS will automatically check all Code Names in the design to ensure name is unique.
Script Access
Defines whether the component will be accessible by script and/or externally, or not at all. Choices include All, External, None (default), and Script.
Tip: Use Script Programmer Mode to quickly view the Script Access setting directly on the component in the design schematic without the need to disconnect from the Q-SYS Core processor.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Controls
- Click
to add a new control to the list, and then configure its properties.
- Click and drag the
icon to re-order the list of controls.
- Select one or more control icons and drag or copy/paste them into your schematic or user control interface. (Use the Ctrl key to select multiple 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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
General Properties
Name
Specify a name for the input.
Count
Specify the number of controls of the specified type to create.
Control Type
Category
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Select a Push Action:
- Momentary: When the button is clicked, it stays in its opposite state until released.
- Toggle: Allows you to turn the button on or off.
- Trigger: Sends a single command.
- State Trigger: Sends a command when conditions are met. See the State Trigger topic.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Specify a Max Value and Min Value for the specified Units:
- dB: -100 to 20
- Hz: 10 to 20000
- Float: (No limit)
- Integer: -999999999 to 99999999
- Pan: -1 to 1
Note: The Pan range is ignored when setting the Pan value. When setting a pan control value in the Block Controller control panel, the valid range is L100 to 0 (or C) to R100. In the Blocks Editor, the valid range is -1 to 1, where -1 is the equivalent of 'L100', 0 is the equivalent of 'C', and 1 is the equivalent of 'R100'. For example, a value of -0.5 is L50, and a value of 0.5 is R50.
- Percent: 0 to 100
- Position: 0 to 1
- Seconds: (No limit)
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Specify a Type: LED, Meter, Text, Status.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Specify a Type: Text Box, Combo Box, List Box
Control Pin
Expose pins for these controls: None, Input (pins on the left), Output (pins on the right), or Both.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
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'
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
See Debug Output.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
The available Control Pins depend on settings in Properties.
Pin Name |
Value |
String |
Position |
Pins Available |
---|---|---|---|---|
Code |
(text) Allows you to enter code. |
Input / Output |
||
Script Start |
(trigger) Starts the script running. |
Input / Output |
||
Script Status |
(text) Current status of the script. |
Output |
||
Script Stop |
(trigger) Stops the script. |
Input / Output |
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
- 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.
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
Using Components with Snapshot Controller Ramp Time
Components such as the Crossover Component or other Text Controller or Custom Controls like the Integer Knobs, and Hexadecimal Knobs will not be recalled by Snapshot if the Ramp Time is a non-zero number.