Named Components

Q-SYS Control 101 Training : Scripting Basics

1 ) Introduction

8m 37s

3 ) Simple Communication

12m 49s

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 4m 42s

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

Video Transcript

Named Components 4m 42s
0:08
Using the Control Tree, there’s actually a third way we can manipulate controls within our script.
0:13
With the Control Script you needed to wire an outside control into your script’s control pins, and with
0:19
Scriptable Controls you can reference a native control built into that component, but you could also
0:25
make use of Named Components.
0:28
A Named Component is exactly what it sounds like – a component that you’ve given a custom name.
0:34
For instance, I’ll drag this Gain block into the design, and when you type on it you can give it any
0:39
name you want. I’ll name mine “RobinHood.” This may seem like just a convenient way to label your
0:45
schematic objects, but under the hood it actually assigns a lua table to that component.
0:51
If you select a Named Component and then go up to the Tools menu, you’ll find an option called
0:57
“View Named Component Info.” This brings up a table of every control inside that Named
1:02
Component – here, I can see the four controls that make up my Gain component. The name on
1:07
the left is its Lua name, and the name on the right is just a description of that control. For a simple
1:13
gain block like this these names are all the same, but if you were to grab a Matrix Mixer, for instance,
1:19
you’d see that the Lua tree is a little more complicated, while the description is here to help you
1:24
understand which control is which.
1:26
Using this Named Component Information, you can actually target your controls from any Lua script,
1:33
without needing to wire the control to that script. Let’s open up a Control Script and do this. The
1:39
syntax looks like this: Component.New, then in parentheses you’ll need to provide the name of your
1:48
Named Component. Since this label is a textual string, you’ll need to put quotes around it. Next you’ll
1:55
need to open up some brackets to specify the name of the control in that Named Component that
2:00
you want to target – which, once again, must be enclosed in quotes. Now that you’ve successfully
2:06
referenced the control itself, you can then continue the control tree to select one of its properties.
2:11
For instance, I’ll change the .Value of RobinHood’s Mute control and set it to 1. When I run the script,
2:20
you can see that it worked!
2:22
Personally, I would recommend using a variable to represent this control. This is an ugly piece of
2:28
code – Component.New-parentheses quotes, brackets quotes – let’s just define variable MrGain as
2:37
that whole thing. Now I can reference that control just by using MrGain.Value or MrGain.String,
2:46
which is a lot easier to look at, and should feel more like the other control tree activities you’ve seen
2:50
so far.
2:52
Named Components are a powerful way to give your scripts access to your controls without using
2:56
wires or Scriptable Controls. It also means that any number of different Lua scripts can reference
3:02
that same control. Basically, this lets you reference something specific that’s not in your script. For
3:09
example, if I were to mention that I’m also a novelist and I wrote a book about Robin Hood, that
3:14
would be a weirdly specific reference that’s definitely not in the script. You can find my book at –
3:23
Well, Nate's fired. So… okay… As "I" was saying, Named Components are an important tool in your
3:36
scripting database. However, there isn’t currently a block in the Block Controller that can represent a
3:41
control found in a Named Component. However, you could still access the Named Component by
3:47
going to the System category, and using the “Lua” block.
3:51
This lets you enter any Lua code you like, specifically for rarer features like this that may not have an
3:57
associated block. I’ll type in the action that I want to perform, such as changing the component Gain
4:05
to -40. In this case, just for variety, let’s use a Trigger button from the Block Controller itself to
4:14
execute this code. I’ll bring this Trigger Button’s “on control change” block, and snap my Lua
4:20
code into the “do” section. Now when I run the script and press the trigger button, the Named
4:28
Component receives the command.
4:31
Well, that's it for Named Components AND for Nate. There's an exercise to complete in the Control
4:36
Worksheet, and then move on whenever you’re ready.