-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBox.ttslua
More file actions
371 lines (358 loc) · 8.18 KB
/
Box.ttslua
File metadata and controls
371 lines (358 loc) · 8.18 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
--[[
SH Expansion Box
Made by Sionar, Lost Savage and Hmmmpf
--]]
------------------Constants
UPDATE_VERSION = 105
ADD_ON_VERSION = 6
BOX_OBJECTS_NUM = 11
ADD_ON_NAME = 'Expansion Deck'
ABILITY_DECK_NAME = 'Abilities'
EFFECT_DECK_NAME = 'Effects'
ABILITY_REFERENCE_NAME = 'Ability Reference'
EFFECT_REFERENCE_NAME = 'Effect Reference'
TOOL_NAME = 'SH Expansion Tool'
RULEBOOK_NAME = 'SH Expansion Rulebook'
LINE_DRAWER_NAME = 'Line Drawer'
CALC_NAME = 'Secret Hitler Probability Calc'
SELF_NAME = 'Counters'
SELF_POS = {20, 1.71, 11}
SELF_SCALE = {2.5, 2.5, 2.5}
SHOWN_ROT = {0,180,0}
HIDDEN_ROT = {0,180,180}
DEFAULT_POS = {0,1,0}
ABILITY_DECK_POS = {-20, 2, 6.25}
EFFECT_DECK_POS = {20, 2, 6.25}
TOOL_POS = {-8,2,-16}
LINE_DRAWER_POS = {8,2,-16}
RULEBOOK_POS = {100, 1.1, -22}
------------------Functions
function onLoad(saveString)
local parameters = {}
parameters.identifier = 'setupExpansionSP'
parameters.function_name = 'setupExpansion'
parameters.function_owner = self
parameters.delay = 0.3
Timer.create(parameters)
self.setDescription('v ' .. VERSION .. '\nMade by Piggy and Sionar')
end
function setupExpansion()
local global_name = Global.getVar('MOD_NAME')
local global_version = Global.getVar('UPDATE_VERSION')
local global_add_on = Global.getVar('ADD_ON_VERSION')
local started = Global.getVar('started')
if not global_add_on then global_add_on = 1 end
if not global_version or global_name ~= 'Secret Hitler: CE' then
printToAll('ERROR: Secret Hitler: CE not found.', {1,0,0})
else
if global_version < UPDATE_VERSION or global_add_on < ADD_ON_VERSION then
printToAll('ERROR: Secret Hitler: CE version is too old; try updating.', {1,0,0})
else
if ADD_ON_VERSION < global_add_on then
printToAll('ERROR: Add on is too old; try updating.', {1,0,0})
else
if started then
printToAll('ERROR: Can not add this option. Game has already started.', {1,0,0})
else
if #self.getObjects() >= BOX_OBJECTS_NUM then
local lastVote_guids = Global.getTable('lastVote_guids')
for _, lastVoteGuid in ipairs(lastVote_guids) do
local lastVote = getObjectFromGUID(lastVoteGuid)
if lastVote then
local txtValue = lastVote.TextTool.getValue()
if txtValue == 'Last Vote' then
txtValue = 'Extra Options: ' .. ADD_ON_NAME
elseif not string.match(txtValue, ADD_ON_NAME) then
txtValue = txtValue .. ', ' .. ADD_ON_NAME
end
lastVote.TextTool.setValue(txtValue)
end
end
local options = Global.getTable('options')
options.expansionAmount = 3
options.expansionOptionEnabled = 5
options.policySafety = false
options.shufflePlayers = true
options.shuffleHost = false
options.voteHistory = true
if options.zoneType ~= 6 then
options.zoneType = 5
end
Global.setTable('options', options)
Global.call('refreshExpansionButtons')
if options.zoneType ~= 6 then
Global.call('refreshHiddenZones')
end
startLuaCoroutine(self, 'setupExpansionCoroutine')
createSnapPoints()
end
end
end
end
end
end
function setupExpansionCoroutine()
self.setPosition(SELF_POS)
self.setScale(SELF_SCALE)
self.setName(SELF_NAME)
self.setLock(true)
local objList = self.getObjects()
local params = {}
for _, v in ipairs(objList) do
if v.name == ABILITY_DECK_NAME then
params.rotation = HIDDEN_ROT
params.guid = v.guid
params.position = ABILITY_DECK_POS
self.takeObject(params)
end
if v.name == EFFECT_DECK_NAME then
params.rotation = HIDDEN_ROT
params.guid = v.guid
params.position = EFFECT_DECK_POS
self.takeObject(params)
end
if v.name == ABILITY_REFERENCE_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = DEFAULT_POS
self.takeObject(params)
end
if v.name == EFFECT_REFERENCE_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = DEFAULT_POS
self.takeObject(params)
end
if v.name == TOOL_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = TOOL_POS
self.takeObject(params)
end
if v.name == RULEBOOK_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = RULEBOOK_POS
self.takeObject(params)
end
if v.name == LINE_DRAWER_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = LINE_DRAWER_POS
self.takeObject(params)
end
if v.name == CALC_NAME then
params.rotation = SHOWN_ROT
params.guid = v.guid
params.position = DEFAULT_POS
self.takeObject(params)
end
end
return true
end
function createSnapPoints()
Global.setSnapPoints(
{
{
position = {9.67,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {13,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {13,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {9.67,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {-19.63,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {-19.63,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {-16.3,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {-16.3,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {33.97,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {37.3,0.96,-18.9},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {33.97,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {37.3,0.96,-23.6},
rotation = {0,180,0},
rotation_snap = true
},
{
position = {36.9,0.96,-4.98},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {36.9,0.96,-1.65},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {41.6,0.96,-4.98},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {41.6,0.96,-1.65},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {36.9,0.96,16.87},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {36.9,0.96,20.2},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {41.6,0.96,16.87},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {41.6,0.96,20.2},
rotation = {0,90,0},
rotation_snap = true
},
{
position = {19.63,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {16.3,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {19.63,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {16.3,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-9.67,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-13,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-9.67,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-13.0,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-33.97,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-37.3,0.96,18.9},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-33.97,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-37.3,0.96,23.6},
rotation = {0,0,0},
rotation_snap = true
},
{
position = {-36.9,0.96,4.98},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-41.6,0.96,4.98},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-36.9,0.96,1.65},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-41.6,0.96,1.65},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-36.9,0.96,-16.87},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-36.9,0.96,-20.2},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-41.6,0.96,-16.87},
rotation = {0,270,0},
rotation_snap = true
},
{
position = {-41.6,0.96,-20.2},
rotation = {0,270,0},
rotation_snap = true
},
}
)
end