-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path07_appearance.lua
More file actions
executable file
·67 lines (57 loc) · 1.49 KB
/
07_appearance.lua
File metadata and controls
executable file
·67 lines (57 loc) · 1.49 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
Appearance = {}
Appearance.__index = Appearance
function Appearance:byName(name)
local obj = ObjectList(string.format("Appearance \"%s\"", name))
if obj == nil then
return nil
end
return Appearance:from(obj[1])
end
function Appearance:from(obj)
local appearance = setmetatable({}, Appearance)
appearance.obj = obj
return appearance
end
function Appearance:byId(id)
local obj = ShowData().Appearances[id]
if obj == nil then
return nil
end
local appearance = setmetatable({}, Appearance)
appearance.obj = obj
return appearance
end
function Appearance:byRange(start, stop)
ret = {}
for n = start, stop do
table.insert(ret, Appearance:byId(n))
end
return ret
end
function Appearance:getOrCreate(id, name)
local appearance = Appearance:byId(id)
if appearance == nil then
appearance = Appearance:create(id)
end
appearance:setName(name)
return appearance
end
function Appearance:create(id)
local obj = ShowData().Appearances:Create(id)
return Appearance:from(obj)
end
function Appearance:setName(name)
self.obj.Name = name
end
function Appearance:address()
return ToAddr(self.obj, false)
end
function Appearance:setFgColor(r, g, b)
self.obj.Color = string.format("%f,%f,%f,1.0", r, g, b)
end
function Appearance:setBgColor(r, g, b)
self.obj.BackR = math.floor(r * 255)
self.obj.BackG = math.floor(g * 255)
self.obj.BackB = math.floor(b * 255)
self.obj.BackAlpha = 255
end