-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGroups.lua
More file actions
201 lines (122 loc) · 4.58 KB
/
Groups.lua
File metadata and controls
201 lines (122 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
--[[
@title: [ Groups.lua ]
@author: [ BakaCowpoke ]
@date: [ 12/23/2025 ]
@description: [ Constructs Group Presets by FixtureType,
as well as by non-recursive Patch "Groupings".
I didn't want to dance with nested Grouping Logic.
One level was enough for me. ]
]]
--[[ alfredPlease Shared Plugin Table (Namespace) Definition
for sharing functions across Plugin Components without making
them Global ]]
local alfredPlease = select(3, ...)
local function buildGroups()
-- Handles for all Patched Fixtures
local allFixtures = ObjectList("Fixture Thru")
--a table to store the FixtureTypes as I pin them down.
local uniqueFixtureTypes = {}
-- Check if the list is not empty
if allFixtures and #allFixtures > 0 then
-- Loop through the ObjectList
for i, fixtureHandle in ipairs(allFixtures) do
local currentFixtureType = fixtureHandle.fixturetype
local currentFixtureTypeName = fixtureHandle.fixturetype.name
local foundCFTName = false
if currentFixtureTypeName == "Grouping" then
--Collecting a table of the FixtureTypes in the patch Groupings
local kidsFT = alfredPlease.listKidsFixtureTypes(fixtureHandle)
--and storing them where I can find them.
uniqueFixtureTypes[fixtureHandle.name] = kidsFT
else
for i, uFTNames in ipairs(uniqueFixtureTypes) do
if currentFixtureTypeName == uFTNames then
foundCFTName = true
end
end
--adds FixtureTypes to the List if they're not listed already.
if foundCFTName == false then
table.insert(uniqueFixtureTypes, currentFixtureType.name)
end
end
end
alfredPlease.storeTheGroups(uniqueFixtureTypes)
else
Echo("* Alfred: I Have Not Found any Fixrtures that need to be Organized into Groupa.")
return
end
end
--[[Making function accessible to other components in this Plugin
via the alfredPlease Shared Table]]
alfredPlease.buildGroups = buildGroups
local function listKidsFixtureTypes(argHandle)
--Generating the table of FixtureTypes in the patch "Grouping"
--[[yeah, I was getting short on Variable names by the
second time I built this logic.]]
local youthfulWard = argHandle:Children()
local returnList = {}
if youthfulWard and #youthfulWard > 0 then
for i, kidHandle in ipairs(youthfulWard) do
local foundMatch = false
local kidsFTName = kidHandle.fixturetype.name
for key, value in pairs(returnList) do
if kidsFTName == value then
foundMatch = true
end
end
if foundMatch == false then
table.insert(returnList, kidsFTName)
end
end
return returnList
end
end
--[[Making function accessible to other components in this Plugin
via the alfredPlease Shared Table]]
alfredPlease.listKidsFixtureTypes = listKidsFixtureTypes
local function storeTheGroups(argTable)
--building the commands to Set & Store the Groups
--validation
if type(argTable) == "table" then
for key, argValue in pairs(argTable) do
local groupCmdSet = ""
local groupCmdStore = ""
CmdIndirectWait("Clear")
--tables here are patch "Groupings"
if type(argValue) == "table" then
local gAppStoreCmd = 'Store Appearance \"'..tostring(key)..'\" Property \"Color\" \"0,0,0,0.0\"'
CmdIndirectWait(gAppStoreCmd)
CmdIndirectWait("Clear")
--[[ Loop to come up with the Set commands for each
Child FixtureType in the patch Grouping ]]
for key, value in pairs(argValue) do
groupCmdSet = 'FixtureType \"' .. value .. '\" /All'
--Printf(groupCmdSet)
CmdIndirectWait(groupCmdSet)
end
groupCmdStore = 'Store Group \"' .. key .. '\" Property \"Appearance\" \"'.. key .. '\" /Universal /Overwrite'
else
--values here are plain single FixtureTypes
local gAppStoreCmd = 'Store Appearance \"'..tostring(argValue)..'\" Property \"Color\" \"0,0,0,0.0\"'
CmdIndirectWait(gAppStoreCmd)
CmdIndirectWait("Clear")
groupCmdSet = 'FixtureType \"' .. argValue .. '\" /All'
groupCmdStore = 'Store Group \"' .. argValue .. '\" Property \"Appearance\" \"'.. argValue .. '\" /Universal /Overwrite'
CmdIndirectWait(groupCmdSet)
end
CmdIndirectWait(groupCmdStore)
CmdIndirectWait("Clear")
end
else
ErrPrintf("Alfred: Having Problems Storing the Groups.")
ErrPrintf("We did Not recieve the expected Table of")
ErrPrintf("FixtureTypes and Groupings.")
end
end
--[[Making function accessible to other components in this Plugin
via the alfredPlease Shared Table]]
alfredPlease.storeTheGroups = storeTheGroups
local function main()
alfredPlease.buildGroups()
end
return main