-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path03_sequences.lua
More file actions
executable file
·311 lines (254 loc) · 6.15 KB
/
Copy path03_sequences.lua
File metadata and controls
executable file
·311 lines (254 loc) · 6.15 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
Sequence = {}
Sequence.__index = Sequence
function Sequence:from(obj)
local instance = setmetatable({}, Sequence)
instance.id = obj.No
instance.obj = obj
return instance
end
function Sequence:byNameOrCreate(name)
local seq = Sequence:byName(name)
if seq == nil then
seq = Sequence:acquire(name)
end
return seq
end
function Sequence:byName(name)
local objs = ObjectList(string.format('Sequence "%s"', name))
if objs == nil then
return nil
end
if #objs == 0 then
return nil
end
return Sequence:from(objs[1])
end
function Sequence:acquire(name)
local seqRaw = DataPool().Sequences:Acquire()
Printf(tostring(seqRaw == nil))
local seq = Sequence:from(seqRaw)
seq.obj.Name = name
return seq
end
function Sequence:get(id)
local obj = DataPool().Sequences[id]
if obj == nil then
return nil
end
local instance = setmetatable({}, Sequence)
instance.id = id
instance.obj = obj
return instance
end
--- @return Sequence
function Sequence:create(id, name)
local instance = setmetatable({}, Sequence)
instance.id = id
Cmd(string.format("ClearAll; Store Sequence %d", id))
instance.obj = DataPool().Sequences[id]--DataPool().Sequences:Create(id)
instance.obj:Dump()
instance.obj.Name = name
return instance
end
function Sequence:findWithTag(tag)
local sequences = {}
local allSequences = ObjectList('Sequence Thru')
for _, sequence in pairs(allSequences) do
if HasTag(sequence.Tags, tag) then
table.insert(sequences, Sequence:from(sequence))
end
end
return sequences
end
function Sequence:getOrCreate(id, name)
local instance = Sequence:get(id)
if instance == nil then
return Sequence:create(id, name)
end
return instance
end
function Sequence:deleteById(id)
DataPool().Sequences:Delete(id)
end
function Sequence:delete()
self:deleteById(self.obj.index)
end
function Sequence:address()
return ToAddr(self.obj, false)
end
function Sequence:setTracking(enabled)
if enabled then
self.obj.Tracking = 1
else
self.obj.Tracking = 0
end
end
function Sequence:setPreferCueAppearance(b)
self.obj.PreferCueAppearance = b
end
function Sequence:setAppearance(appearance)
self.obj.Appearance = appearance.obj
end
function Sequence:addCue()
local obj = self.obj:Insert(#self.obj + 1)
obj.No = string.format("%i.0", #self.obj - 2)
obj:Create(1).Part = 0
return Cue:from(obj)
end
function Sequence:getCue(cueId)
local cue = self.obj[cueId + 2]
if cue ~= nil then
return Cue:from(cue)
end
return nil
end
function Sequence:getOrCreateCue(cueId)
if #self.obj - 2 >= cueId then
local cue = self:getCue(cueId)
if cue ~= nil then
return cue
end
end
while #self.obj < cueId + 2 do
cue = self:addCue()
end
return cue
end
function Sequence:getName()
return self.obj.Name
end
function Sequence:setName(name)
self.obj.Name = name
end
function Sequence:children()
local ret = {}
for _, cue in pairs(self.obj:Children())
do
table.insert(ret, Cue:from(cue))
end
return ret
end
function Sequence:deleteCue(cue)
self.obj:Delete(cue.obj.index)
end
function Sequence:deleteAllCues()
for i, cue in pairs(self.obj:Children())
do
self.obj:Delete(i)
end
end
Cue = {}
Cue.__index = Cue
function Cue:from(obj)
local instance = setmetatable({}, Cue)
instance.obj = obj
return instance
end
function Cue:setTrackingDistance(dist)
self.obj.TrackingDistance = dist
end
function Cue:address()
return ToAddr(self.obj, false)
end
function Cue:getCuePart(partId)
local partObj = self.obj[partId + 1]
if partObj == nil then
while #self.obj < (partId + 1) do
partObj = self.obj:Insert(#self.obj + 1)
partObj.Part = #self.obj - 1
Printf(partObj.Part)
end
end
return CuePart:from(partObj)
end
function Cue:setCommand(cmdLine)
self:getCuePart(0):setCommand(cmdLine)
end
function Cue:setAppearance(appearance)
self:getCuePart(0):setAppearance(appearance)
end
function Cue:getAppearance()
return self:getCuePart(0):getAppearance()
end
function Cue:setName(name)
self:getCuePart(0):setName(name)
end
function Cue:getName()
return self:getCuePart(0):getName()
end
TRIGGER_TYPE_GO = "Go"
TRIGGER_TYPE_FOLLOW = "Follow"
function Cue:setTriggerType(type, value)
self.obj.TrigType = type
if value ~= nil then
self.obj.TrigTime = value
end
end
function Cue:setFadeTime(t)
self:getCuePart(1).obj.CueInFade = t
end
CuePart = {}
CuePart.__index = CuePart
function CuePart:from(obj)
local instance = setmetatable({}, CuePart)
instance.obj = obj
return instance
end
function CuePart:address()
return ToAddr(self.obj, false)
end
function CuePart:addRecipe()
local obj = self.obj:Insert(#self.obj + 1)
return Recipe:from(obj)
end
function CuePart:getOrCreateRecipe(id)
local obj = self.obj[id]
if obj == nil then
local recipe = self:addRecipe()
while #self.obj < id do
recipe = self:addRecipe()
end
return recipe
end
return Recipe:from(obj)
end
function CuePart:setCommand(cmd)
self.obj.Command = cmd
end
function CuePart:setAppearance(appearance)
self.obj.Appearance = appearance.obj
end
function CuePart:getAppearance()
if self.obj.Appearance == nil then
return nil
end
return Appearance:from(self.obj.Appearance)
end
function CuePart:setName(name)
self.obj.Name = name
end
function CuePart:getName()
return self.obj.Name
end
Recipe = {}
Recipe.__index = Recipe
function Recipe:from(obj)
local instance = setmetatable({}, Recipe)
instance.obj = obj
return instance
end
function Recipe:address()
return ToAddr(self.obj, false)
end
function Recipe:setName(name)
self.obj.Name = name
end
function Recipe:setSelection(group)
self.obj.Selection = group.obj
end
function Recipe:setValue(preset)
self.obj.Values = preset.obj
end
function Recipe:setMATricks(preset)
self.obj.MATricks = preset.obj
end