-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path99_builder.lua
More file actions
executable file
·182 lines (150 loc) · 3.62 KB
/
99_builder.lua
File metadata and controls
executable file
·182 lines (150 loc) · 3.62 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
Builder = {}
Builder.__index = Builder
function Builder:new()
local builder = setmetatable({}, Builder)
builder.op = {}
return builder
end
function Builder:debug()
Printf("Would exec %s", self:str())
return self
end
function Builder:delete(obj)
table.insert(self.op, "Delete")
self:addItem(obj)
return self
end
function Builder:ifTag(tag)
table.insert(self.op, string.format("If Tag \"%s\"", tag))
return self
end
function Builder:str()
return table.concat(self.op, " ")
end
function Builder:debug()
Printf("Debug %s", self:str())
return self
end
function Builder:exec()
Cmd(self:str())
end
function Builder:obj(obj)
table.insert(self.op, obj:address())
return self
end
function Builder:store(obj)
table.insert(self.op, "Store")
self:addItem(obj)
return self
end
function Builder:add(str)
table.insert(self.op, str)
return self
end
function Builder:merge()
table.insert(self.op, "/merge")
return self
end
function Builder:assign(obj)
table.insert(self.op, "Assign")
self:addItem(obj)
return self
end
function Builder:copy(obj)
table.insert(self.op, "Copy")
table.insert(self.op, obj:address())
return self
end
function Builder:thru(obj)
table.insert(self.op, "Thru")
if type(obj) == "string" then
table.insert(self.op, obj)
elseif type(obj) == "number" then
table.insert(self.op, string.format("%d", obj))
else
table.insert(self.op, string.format("%d", obj.obj.No))
end
return self
end
function Builder:at(obj)
table.insert(self.op, "At")
self:addItem(obj)
return self
end
function Builder:gotoObj()
table.insert(self.op, "goto")
return self
end
function Builder:sequence(seq)
table.insert(self.op, seq:address())
return self
end
function Builder:cue(id)
table.insert(self.op, string.format("Cue %d", id))
return self
end
function Builder:part(id, elem)
if elem ~= nil then
table.insert(self.op, string.format("Part %d.%d", id, elem))
else
table.insert(self.op, string.format("Part %d", id))
end
return self
end
function Builder:layoutItem(obj)
self:addItem(obj, "Layout")
return self
end
function Builder:addItem(obj)
if type(obj) == "table" then
if obj[1] == nil then
table.insert(self.op, obj:address())
else
objects = {}
for _, o in pairs(obj) do
table.insert(objects, o:address())
end
table.insert(self.op, table.concat(objects, " + "))
end
elseif type(obj) == "string" then
table.insert(self.op, obj)
elseif type(obj) == "number" then
table.insert(self.op, string.format("%d", obj))
end
return self
end
function Builder:noConfirm()
table.insert(self.op, "/nc")
return self
end
function Builder:noUndo()
return self:noOops()
end
function Builder:noOops()
table.insert(self.op, "/NoOops")
return self
end
function Builder:next()
table.insert(self.op, ";")
return self
end
function Builder:noteOn(channel, note, velocity)
table.insert(self.op, string.format("SendMidi \"Note\" %d/%d %d; ", channel, note, velocity))
return self
end
function Builder:go(obj)
table.insert(self.op, "Go+")
table.insert(self.op, obj:address())
return self
end
function Builder:set(obj)
table.insert(self.op, "Set")
self:addItem(obj)
return self
end
function Builder:property(prop, obj)
table.insert(self.op, "Property")
table.insert(self.op, string.format("'%s'", prop))
table.insert(self.op, string.format("'%s'", obj))
return self
end