forked from sionar/Botc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomBagBuilder.ttslua
203 lines (193 loc) · 7.44 KB
/
CustomBagBuilder.ttslua
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
function bagTable(params)
local bag = {}
local entry = {}
bag.Name = 'Bag'
bag.Transform = {
posX = params.position[1],
posY = params.position[2],
posZ = params.position[3],
rotX = 0,
rotY = 0,
rotZ = 0,
scaleX = 1,
scaleY = 1,
scaleZ = 1
}
bag.Nickname = params.Nickname or ''
bag.Description = params.Description or ''
bag.GMNotes = ''
bag.ColorDiffuse = params.ColorDiffuse
bag.Locked = false
bag.Grid = true
bag.Snap = true
bag.IgnoreFoW = false
bag.Autoraise = true
bag.Sticky = true
bag.Tooltip = true
bag.GridProjection = false
bag.HideWhenFaceDown = false
bag.Hands = false
bag.MaterialIndex = -1
bag.MeshIndex = -1
bag.XmlUI = ''
bag.LuaScript = ''
bag.ContainedObjects = {}
if not (params.reminder) then
for i = #params.characters, 1, -1 do
entry = {}
entry.Name = 'Custom_Token'
entry.Transform = {
posX = 0,
posY = 0,
posZ = 0,
rotX = 0,
rotY = 0,
rotZ = 0,
scaleX = 1,
scaleY = 1,
scaleZ = 1,
}
entry.Nickname = string.gsub(params.characters[i], '_', ' ')
entry.Description = CHARACTERS[params.characters[i]].Type
entry.GMNotes = 'Character Token'
entry.ColorDiffuse = {r = 1, g = 1, b = 1}
entry.Locked = false
entry.Grid = false
entry.Snap = true
entry.IgnoreFoW = false
entry.Autoraise = true
entry.Sticky = true
entry.Tooltip = false
entry.GridProjection = false
entry.HideWhenFaceDown = true
entry.Hands = true
entry.CustomImage = {
ImageURL = DECAL_URLS[params.characters[i]],
ImageSecondaryURL = '',
ImageScalar = 1.0,
WidthScale = 0.0,
CustomToken = {
Thickness = 0.2,
MergeDistancePixels = 25.0,
Stackable = false
}
}
entry.XMLUI = ''
entry.LuaScript = ''
entry.LuaScriptState = ''
entry.GUID = ''
table.insert(bag.ContainedObjects, entry)
end
else
for _, name in pairs(params.characters) do
if REMINDER_TOKENS[name] then
for k,v in pairs(REMINDER_TOKENS[name]) do
for i = 1, v.num do
entry = {}
entry.Name = 'Custom_Token'
entry.Transform = {
posX = 0,
posY = 0,
posZ = 0,
rotX = 0,
rotY = 0,
rotZ = 0,
scaleX = 0.5,
scaleY = 1,
scaleZ = 0.5,
}
entry.Nickname = string.gsub(name, '_', ' ')
entry.Description = 'Reminder Token'
entry.GMNotes = ''
entry.ColorDiffuse = {r = 1, g = 1, b = 1}
entry.Locked = false
entry.Grid = false
entry.Snap = true
entry.IgnoreFoW = false
entry.Autoraise = true
entry.Sticky = true
entry.Tooltip = false
entry.GridProjection = false
entry.HideWhenFaceDown = true
entry.Hands = true
entry.CustomImage = {
ImageURL = v.url,
ImageSecondaryURL = '',
ImageScalar = 1.0,
WidthScale = 0.0,
CustomToken = {
Thickness = 0.2,
MergeDistancePixels = 25.0,
Stackable = false
}
}
entry.XMLUI = ''
entry.LuaScript = ''
entry.LuaScriptState = ''
entry.GUID = ''
table.insert(bag.ContainedObjects, 1, entry)
end
end
end
end
end
return bag
end
function spawnBag(params)
local bagTable = bagTable({
Nickname = params.Nickname,
Description = params.Description,
ColorDiffuse = params.ColorDiffuse,
characters = params.characters,
position = params.position,
reminder = params.reminder,
})
spawnObjectData({data = bagTable, position = params.position, rotation = {0,0,0}})
end
function spawnSet(characters, name)
local objs = getAllObjects()
local reminderbagTable
for k,v in pairs(objs) do
if string.match(v.getName(), ': Demons')
or string.match(v.getName(), ': Minions')
or string.match(v.getName(), ': Outsiders')
or string.match(v.getName(), ': Townsfolk')
or string.match(v.getName(), ': Travelers')
or string.match(v.getName(), ': Reminder') then
v.destruct()
end
end
local chars = {
Townsfolk = {},
Outsider = {},
Minion = {},
Demon = {},
Traveler = {}
}
for k,v in pairs(characters) do
table.insert(chars[CHARACTERS[v].Type], v)
if v == 'Farmer' then
for i = 1,12 do
table.insert(chars[CHARACTERS[v].Type], v)
end
elseif v == 'Legion' then
for i = 1,14 do
table.insert(chars[CHARACTERS[v].Type], v)
end
end
end
local reminderChars = {}
for k1,v1 in pairs(TYPES) do
for k2,v2 in pairs(characters) do
if CHARACTERS[v2].Type == v1 then
table.insert(reminderChars, v2)
end
end
end
spawnBag({Nickname = name .. ': Townsfolk', Description = '', ColorDiffuse = {r = 36/255, g = 35/255, b = 250/255}, characters = chars.Townsfolk, position = {10, 0.82, 111.5 + TABLE_OFFSET}, reminder = false})
spawnBag({Nickname = name .. ': Outsiders', Description = '', ColorDiffuse = {r = 33/255, g = 177/255, b = 155/255}, characters = chars.Outsider, position = {6, 0.82, 111.5 + TABLE_OFFSET}, reminder = false})
spawnBag({Nickname = name .. ': Minions', Description = '', ColorDiffuse = {r = 244/255, g = 100/255, b = 29/255}, characters = chars.Minion, position = {2, 0.82, 111.5 + TABLE_OFFSET}, reminder = false})
spawnBag({Nickname = name .. ': Demons', Description = '', ColorDiffuse = {r = 219/255, g = 26/255, b = 24/255}, characters = chars.Demon, position = {-2, 0.82, 111.5 + TABLE_OFFSET}, reminder = false})
spawnBag({Nickname = name .. ': Travelers', Description = '', ColorDiffuse = {r = 0/255, g = 213/255, b = 47/255}, characters = chars.Traveler, position = {-6, 0.82, 111.5 + TABLE_OFFSET}, reminder = false})
spawnBag({Nickname = name .. ': Reminder Tokens', Description = '', ColorDiffuse = {r = 241/255, g = 212/255, b = 162/255}, characters = reminderChars, position = {-10, 0.82, 111.5 + TABLE_OFFSET}, reminder = true})
end