Named Components

Q-SYS Control 101 Training : Scripting Basics
The methods described in this video exist on Q-SYS Designer version 9.5 and higher. Prior to 9.5, the “Label”, “Code Name” and “Script Access” properties do not exist. To name a component in these earlier versions, simply change the component’s name in the schematic, and use that name as a reference in your Block Controller or Text Controller scripts.

3 ) Simple Communication

15m 13s

4 ) Feature License Activation

4m 12s

5 ) Block Controller

19m 7s

7 ) Flow Control

34m 20s

8 ) Control 101 Conclusion

1m 42s

Lesson Description

Named Components 5m 43s

Use the "View Named Components List" tool to access your controls from any script in the design.

Video Transcript

Named Components 5m 43s
00:08
Using the Control Tree, there’s actually a third way we can manipulate controls within our script.
00:13
With the Control Script you needed to wire an outside control into your script’s control pins,
00:18
and with Scriptable Controls you can reference a native control built into that component, but you could also make use of Named Components.
00:28
A Named Component is exactly what it sounds like: a component that you’ve given a custom name. For instance, I’ll drag this Gain block into the design, and let’s look at its properties.
00:39
One of its properties is called “Label,” which is just the friendly name displayed on the component in the schematic.
00:45
But there’s another property called “Code Name.” I’ll give my Gain component a sneaky code name like . . . “RobinHood.”
00:54
This is quite different than changing its label, because under the hood, this is assigning a Lua table to my component.
01:03
The component is still visually labeled “Gain,” but if I hover my mouse over it I can confirm its secret code name of RobinHood.
01:11
Using this Code Name, you can actually target your component’s controls from any Lua script, without needing to wire the control to that script.
01:20
For instance, if you open up a Block Controller, you’ll see a branch for your Named Components on the left for every component that is accessible by a Code Name.
01:30
This way, I might use a Trigger button here in the Block Controller to change the Named Component’s gain knob to -40dB.
01:42
Now when I tap the Trigger button, you can see that the Named Component was successfully changed.
01:48
For those of you prefer Lua, let’s open up a Control Script and target the component from there as well.
01:55
The syntax looks like this: Component.New, then in parentheses you’ll need to provide the Code Name of the Named Component.
02:06
Since this text is a string, you’ll need to put quotes around it.
02:10
Next you’ll need to open up some brackets to specify the name of the control within that component that you want to target, which once again, must be enclosed in quotes.
02:21
If you’re not sure what the names of the controls inside the component are, you can select the Component and go to the Tools menu, and select “View Component Controls Info.”
02:32
This will display the Lua name for each control on the left, as well as a friendly name for it and what type of control it is on the right.
02:41
Now that you’ve successfully referenced the control itself, you can then continue the Control Tree to select one of its properties.
02:48
For instance, I’ll change the .Value of Robin Hood’s Mute control. And when I run the script, you can see that it worked.
02:56
Personally, I would recommend using a variable to represent this control.
03:01
This is an ugly piece of code – Component.New-parentheses quotes, brackets quotes – let’s just define variable MrGain as that whole thing.
03:13
Now I can reference that control just by using MrGain.Value or MrGain.String, which is a lot easier to look at, and should feel more like the other control tree activities you’ve seen so far.
03:26
Named Components are a powerful way to give your scripts access to your controls without using wires or Scriptable Controls.
03:33
It also means that any number of different Lua scripts can reference that same control.
03:38
Basically, this lets you reference something specific that’s not in your script.
03:43
For example, if I were to mention that I’m also a novelist and I wrote a book about Robin Hood, that would be a weirdly specific reference that’s definitely not in the script.
03:53
You can find my book at...
03:58
Well, Nate's fired... so...
04:06
As I was saying, Named Components are an important tool in your scripting database. You should also be aware of the “Script Access” property.
04:16
You might have noticed that when you change the component’s Code Name, the “Script Access” property also changed from “None” to “All.”
04:24
By default your components start in the safest mode of not allowing any external access,
04:30
but Q-SYS is assuming that if you’re giving this component a Code Name, you want it to be controllable.
04:36
You could also customize this field to “Script,” which only allows internal scripts to access your component, or “External,” which only allows external devices to do so.
04:47
Finally, there’s another option available under the Tools menu called “Script Programmer Mode.”
04:54
When this mode is engaged, the Label and the Code Name for each of these components are visually reversed, so you can see each component’s Code Name displayed prominently,
05:04
and its Label will only be visible when you hover your mouse over the component.
05:08
In this mode, renaming the component here in the Schematic will update its Code Name rather than its Label, so be sure to keep track of which mode you’re in.
05:18
You’ll also notice that every component displays a small colored square indicating its Script Access property: red for All, amber for External, yellow for Scripts, and grey for None.
05:30
Well, that’s it for Named Components, and for Nate. There’s an exercise to complete in the Control Worksheet, and then move on whenever you’re ready.