-
Notifications
You must be signed in to change notification settings - Fork 4
/
ClockControls.ttslua
905 lines (820 loc) · 29.4 KB
/
ClockControls.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
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
--[[
Clock Controls
Made by Unreal_ed, modified by Sionar
--]]
------------------Constants
VERSION = '1.11.4'
UI_SCALE = {0.5, 0.5, 0.5} -- to resize scale of the buttons all at once
COLORS = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink'}
COLORS_EX = {'Magenta', 'Lavender', 'Navy', 'Cyan', 'Mint', 'Lime', 'Peach', 'Coral', 'Maroon', 'Silver'}
COLORS_ALL = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink', 'Magenta', 'Lavender', 'Navy', 'Cyan', 'Mint', 'Lime', 'Peach', 'Coral', 'Maroon', 'Silver'}
COLORS_EX_HEX = {Magenta = {255/255, 0/255,127/255}, Lavender = {150/255,123/255,182/255}, Navy = {0,0,128/255}, Cyan = {73/255, 213/255,253/255}, Mint = {137/255, 195/255,129/255}, Lime = {184/255,241/255,97/255}, Peach = {241/255, 212/255,162/255}, Coral = {226/255,154/255,138/255}, Maroon = {128/255,0,0}, Silver = {190/255, 190/255,190/255}}
BLACK_ZONE = {guid = '2ae7fa', scale = {67, 11, 70}}
CLOCK_HAND_SCALE = {
{hour = {1.5, 1, 1.5}, minute = {2.5, 1, 2.5}, second = {3, 1, 3}},
{hour = {5, 1, 5}, minute = {7.4, 1, 7.4}, second = {7.5, 1, 7.5}}
}
CLOCK_IMAGE_URLS = {
{
clock = 'http://cloud-3.steamusercontent.com/ugc/1268275024974789335/1785ECED9E80E47CBF2C3C35CDA30D94646B200E/',
hour = 'http://cloud-3.steamusercontent.com/ugc/1268275024975141607/27677052211F1DD742A40E0202E8FFB02D26DE88/',
minute = 'http://cloud-3.steamusercontent.com/ugc/1268275024975141995/1A37289A1CA458FFB6E6F7373BD662892F3E56FD/',
second = 'http://cloud-3.steamusercontent.com/ugc/1268275024975164579/5FC2F72E546064FDF6C099324FE21C57E4BF86E3/'
},
{
clock = 'http://cloud-3.steamusercontent.com/ugc/787490852828176792/8039D7C9DC16DD10734E9C45089AA95BF376BD7C/',
hour = 'http://cloud-3.steamusercontent.com/ugc/800993691916835212/ED4EE0172781713E7993BCB93B02E146B15793AF/',
minute = 'http://cloud-3.steamusercontent.com/ugc/800993691916835503/BDAF1BFB16216E9ECABE83B350458194C73D92D5/',
second = 'http://cloud-3.steamusercontent.com/ugc/800993691916835748/F438F463E3C6693F3FA7C1FF4CAB035308139618/'
}
}
BUTTON_COLOR = {0,0,0}
BUTTON_FONT_COLOR = {1,1,1}
#include GUIDs.ttslua
------------------Variables
objects = {}
pointedPlayer = 'None'
mode = 'Clock'
clockOn = false
rotating = false
rotationRate = 24
degreesRotated = 0
tolerance = 3 -- how few degrees off of the perfect rotation degrees will register for locking the voting cards
grimShow = false
extension = false
votingMode = ''
allMuted = false
allBlind = false
handRotation = {}
colors = {}
clockStyle = 1
tableSize = 10
muted = {}
votesNeeded = 0
------------------Functions
function onLoad(saveString)
if not (saveString == '') then
local save = JSON.decode(saveString)
allMuted = save['am']
allBlind = save['ab']
clockOn = save['co']
handRotation = save['h']
colors = save['c']
clockStyle = save['cs']
end
assignObjects()
objects.clock.interactable = false
objects.secondHand.interactable = false
objects.minuteHand.interactable = false
objects.hourHand.interactable = false
colors = Global.getTable('colors')
handRotation = Global.getTable('angle')
for k,v in pairs(colors) do
handRotation[v] = (handRotation[v] + 180)%360
end
TABLE_OFFSET = Global.getVar('TABLE_OFFSET')
refreshButtons()
hideGrimoire()
generateMuteTable()
end
function assignObjects()
objects.clock = getObjectFromGUID(CLOCK_GUID)
objects.secondHand = getObjectFromGUID(SECOND_HAND_GUID)
objects.minuteHand = getObjectFromGUID(MINUTE_HAND_GUID)
objects.hourHand = getObjectFromGUID(HOUR_HAND_GUID)
objects.nightHelper = getObjectFromGUID(NIGHT_HELPER_GUID)
objects.teamTool = getObjectFromGUID(TEAM_TOOL_GUID)
objects.guillotine = getObjectFromGUID(GUILLOTINE_GUID)
objects.blackZone = getObjectFromGUID(BLACK_ZONE.guid)
end
function onSave()
local save = {}
save['am'] = allMuted
save['ab'] = allBlind
save['co'] = clockOn
save['h'] = handRotation
save['c'] = colors
save['cs'] = clockStyle
local saveString = JSON.encode(save)
return saveString
end
function onPlayerConnect(player)
if allBlind then
player.blindfolded = true
end
muted[player.steam_id] = false
end
function onPlayerDisconnect(player)
muted[player.steam_id] = false
end
function onFixedUpdate()
if rotating and degreesRotated < 360 then
currentRot = objects.secondHand.getRotation()
objects.secondHand.setRotation({currentRot.x, currentRot.y + rotationRate*Time.fixed_delta_time, currentRot.z})
degreesRotated = degreesRotated + rotationRate*Time.fixed_delta_time
local params = {}
for k,v in pairs(colors) do
if math.abs(handRotation[v] - currentRot.y) < tolerance and degreesRotated > 10 then
params.color = v
end
end
if params.color ~= nil then
Global.call('setVoteLock', params)
end
elseif rotating and degreesRotated >= 360 then -- if it's done rotating
degreesRotated = 0
toggleClockMovement(_, 'Black')
Global.call('updateVoteResults', {voteMode = votingMode})
pointedPlayer = 'None'
end
end
function generateMuteTable()
for k,v in pairs(Player.getPlayers()) do
if muted[v.steam_id] == nil then
muted[v.steam_id] = false
end
end
end
function updateSettings()
colors = Global.getTable('colors')
handRotation = Global.getTable('angle')
for k,v in pairs(colors) do
handRotation[v] = (handRotation[v]+180)%360
end
refreshButtons()
end
function toggleClockNom(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
toggleClock('execution')
end
function toggleClockExile(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
toggleClock('exile')
end
function toggleClock(vm)
local started = Global.getVar('started')
local tableSize = Global.getVar('tableSize')
local lifeTokens = Global.getTable('lifeTokens')
if clockOn then --if clock is CURRENTLY up
clockOn = false
objects.secondHand.setScale({0, 1, 0})
objects.secondHand.setPosition({0,-20, 0 + TABLE_OFFSET})
objects.minuteHand.setScale({0, 1, 0})
objects.minuteHand.setPosition({0,-20, 0 + TABLE_OFFSET})
objects.hourHand.setScale({0, 1, 0})
objects.hourHand.setPosition({0,-20, 0 + TABLE_OFFSET})
objects.clock.setScale({0, 1, 0})
objects.clock.setPosition({0, -20, 0 + TABLE_OFFSET})
UI.setAttribute('nomMenu', 'active', 'false')
UI.setAttribute('colorSelection', 'active', 'false')
if vm == 'execution' or mode == 'Clock' then
self.editButton({index = 0, label = 'Show Clock', color = {40/255, 47/255, 85/255}, font_color = BUTTON_FONT_COLOR})
end
self.editButton({index = 1, scale = {0, 0, 0}})
self.editButton({index = 8, label = 'Exile\nClock', tooltip = 'Show the clock for exiling a traveler.'})
Global.call('hideVoteButtons')
Global.call('hideVotehands')
if started then
Global.setVar('notes', '')
end
votingMode = ''
if rotating then
toggleClockMovementButton(rotating)
rotating = false
end
if vm == 'execution' then
objects.guillotine.setPositionSmooth({26,1,111 + TABLE_OFFSET})
objects.guillotine.setRotationSmooth({0,0,0})
objects.guillotine.setLock(false)
end
Global.setVar('currMostVotes', 0)
else -- if clock is CURRENTLY down
clockOn = true
Global.call('showVoteButtons', {voteMode = vm})
Global.call('resetVotes', {voteMode = vm})
objects.teamTool.call('removeAll')
votingMode = vm
votesNeeded = 0
objects.secondHand.setScale(CLOCK_HAND_SCALE[clockStyle].second)
objects.secondHand.setPosition({0, 1.4, 0 + TABLE_OFFSET})
objects.minuteHand.setScale(CLOCK_HAND_SCALE[clockStyle].minute)
objects.minuteHand.setPosition({0, 1.6, 0 + TABLE_OFFSET})
objects.hourHand.setScale(CLOCK_HAND_SCALE[clockStyle].hour)
objects.hourHand.setPosition({0, 1.8, 0 + TABLE_OFFSET})
objects.clock.setScale({28, 1, 28})
objects.clock.setPosition({0, 1, 0 + TABLE_OFFSET})
UI.setAttribute('nomMenu', 'active', 'true')
UI.setAttribute('colorSelection', 'active', 'false')
self.editButton({index = 0, label = 'Hide Clock', color = {1, 0, 0}})
self.editButton({index = 1, scale = UI_SCALE})
self.editButton({index = 8, label = 'Hide\nClock', tooltip = 'Hide the objects.clock.'})
pointHand({hand = objects.secondHand, color = 'None'})
pointHand({hand = objects.minuteHand, color = 'None'})
pointHand({hand = objects.hourHand, color = 'None'})
if vm == 'execution' then
objects.guillotine.setPositionSmooth({0,2,0 + TABLE_OFFSET})
objects.guillotine.setRotationSmooth({0,180,0})
objects.guillotine.setLock(true)
end
end
end
function toggleClockMovement(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
if pointedPlayer == 'None' then
broadcastToColor('Pick a player to nominate with the nomination buttons.', playerColor, {1,0,0})
return
end
local currentNominator = Global.getVar('currentNominator')
if currentNominator == '' then
broadcastToColor('Select a nominator with the nomination buttons.', playerColor, {1,0,0})
return
end
local actionStr, numAlive, numPlayers, minVotes
local players
if votingMode == 'execution' then
actionStr = 'execute'
else
actionStr = 'exile'
end
if rotating == false then
players = Global.call('updatePlayers')
toggleClockMovementButton(rotating)
rotating = true
numAlive = Global.getVar('numAlive')
numPlayers = Global.getVar('numPlayers')
if votingMode == 'execution' then
minVotes = math.ceil(numAlive/2)
if minVotes > votesNeeded then
votesNeeded = minVotes
end
else
votesNeeded = math.ceil(numPlayers/2)
end
if players[pointedPlayer] ~= nil then
broadcastToAll('Start voting now! '.. votesNeeded ..' votes are needed to ' .. actionStr .. ' ' .. pointedPlayer .. '.', 'Red')
end
else
toggleClockMovementButton(rotating)
rotating = false
end
end
function toggleClockMovementButton(currentlyRotating)
if currentlyRotating == false then
self.editButton({index = 1, label = 'Stop Clock', color = {1, 0, 0}})
else
self.editButton({index = 1, label = 'Start Clock', color = {40/255, 47/255, 85/255}})
end
end
function pointHand(params)
local hand = params.hand
local color = params.color
local rotValue = handRotation[color]
if color == 'None' then
rotValue = 180
end
if rotating then
toggleClockMovement(_, 'Black')
Global.call('resetVotes', {voteMode = votingMode})
end
hand.setRotationSmooth({0, rotValue, 180})
degreesRotated = 0
if hand == objects.minuteHand then
pointedPlayer = color
end
end
for k,v in pairs(COLORS_ALL) do
_G['pointTo' .. v] = function(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
local canBeNominated = Global.getTable('canBeNominated')
if canBeNominated[v] == false then
return
end
if rotating then
degreesRotated = 0
toggleClockMovement(_, 'Black')
Global.call('resetVotes', {voteMode = votingMode})
end
local players = Global.call('updatePlayers')
local voteButtonsOn = Global.getTable('voteButtonsOn')
if voteButtonsOn[v] == false then
return
end
if objects.clock.getScale().x == 0 then
return
end
pointHand({hand = objects.minuteHand, color = v})
pointHand({hand = objects.secondHand, color = v})
local callParams = {}
callParams.player = 'Black'
callParams.target = v
Global.call('nominated', callParams)
end
end
function setRotValue(obj, color, value, stillEditing)
if not stillEditing then
if color ~= 'Black' then
refreshButtons()
return
end
rotationRate = tonumber(value)
if rotationRate == nil then
rotationRate = 12
refreshButtons()
end
end
end
function plusRot(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
rotationRate = rotationRate + 6
self.editInput({
index = 0,
value = rotationRate,
})
end
function minusRot(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
rotationRate = rotationRate - 6
self.editInput({
index = 0,
value = rotationRate,
})
end
function toggleModeClock(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
mode = 'Clock'
if objects.clock.getScale().x ~= 0 then --if clock is CURRENTLY up
self.editButton({
index = 0,
click_function = 'toggleClockNom',
label = 'Hide Clock',
color = {1,0,0},
font_color = BUTTON_FONT_COLOR,
})
else
self.editButton({
index = 0,
click_function = 'toggleClockNom',
label = 'Show Clock',
color = {40/255, 47/255, 85/255},
font_color = BUTTON_FONT_COLOR,
})
end
for i, c in ipairs(colors) do
self.editButton({
index = 8 + i,
click_function = 'pointTo'..c,
tooltip = 'Point the clock to '..c,
})
end
self.editButton({
index = 4, -- the mode toggle button
color = {40/255, 47/255, 85/255},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 5, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 6, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
end
function toggleModeBlind(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
mode = 'Blind'
local label = 'Blindfold All'
local color = {40/255, 47/255, 85/255}
if allBlind then
label = 'Unblindfold All'
color = {1, 0, 0}
end
self.editButton({
index = 0,
click_function = 'blindfoldAll',
label = label,
color = color,
font_color = BUTTON_FONT_COLOR,
})
for i, c in ipairs(colors) do
self.editButton({
index = 8 + i,
click_function = 'blindfold'..c,
tooltip = 'Blindfold player '..c,
})
end
self.editButton({
index = 4, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 5, -- the mode toggle button
color = {40/255, 47/255, 85/255},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 6, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
end
function toggleModeMute(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
mode = 'Mute'
local label = 'Mute All'
local color = {40/255, 47/255, 85/255}
if allMuted then
label = 'Unmute All'
color = {1, 0, 0}
end
self.editButton({
index = 0,
click_function = 'muteAll',
label = label,
color = color,
font_color = BUTTON_FONT_COLOR,
})
for i, c in ipairs(colors) do
self.editButton({
index = 8 + i,
click_function = 'mute'..c,
tooltip = 'Mute player '..c,
})
end
self.editButton({
index = 4, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 5, -- the mode toggle button
color = {0,0,0},
font_color = BUTTON_FONT_COLOR,
})
self.editButton({
index = 6, -- the mode toggle button
color = {40/255, 47/255, 85/255},
font_color = BUTTON_FONT_COLOR,
})
end
function toggleBlindfold(color)
local players = Global.call('updatePlayers')
local player = players[color]
if player == nil then
return
end
if player.blindfolded == true then
if objects.nightHelper ~= nil then
local unblind = objects.nightHelper.getTable('unblind')
table.insert(unblind, color)
objects.nightHelper.setTable('unblind', unblind)
end
player.blindfolded = false
else
player.blindfolded = true
end
end
for k,v in pairs(COLORS_ALL) do
_G['blindfold' .. v] = function(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
toggleBlindfold(v)
end
end
function blindfoldAll(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
allBlind = not allBlind
local allPlayers = Player.getPlayers()
if allBlind then
self.editButton({index = 0, label = 'Unblindfold All', color = {1,0,0}})
for k, v in pairs(allPlayers) do
if v.color ~= 'Black' then
v.blindfolded = true
end
end
Global.call('resetNotes')
else
self.editButton({index = 0, label = 'Blindfold All', color = {40/255, 47/255, 85/255}})
for k, v in pairs(allPlayers) do
if v.color ~= 'Black' then
v.blindfolded = false
end
end
end
end
for k,v in pairs(COLORS_ALL) do
_G['mute' .. v] = function(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
local players = Global.call('updatePlayers')
local player = players[v]
if player ~= nil then
player.mute()
muted[player.steam_id] = not muted[player.steam_id]
end
end
end
function muteAll(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
allMuted = not allMuted
local allPlayers = Player.getPlayers()
if allMuted then
self.editButton({index = 0, label = 'Unmute All', color = {1,0,0}})
else
self.editButton({index = 0, label = 'Mute All', color = {40/255, 47/255, 85/255}})
end
if allMuted then
for k, v in pairs(allPlayers) do
if v.color ~= 'Black' and not muted[v.steam_id] then
v.mute()
muted[v.steam_id] = true
end
end
else
for k, v in pairs(allPlayers) do
if v.color ~= 'Black' and muted[v.steam_id] then
v.mute()
muted[v.steam_id] = false
end
end
end
end
function toggleHiddenZones(clickedObject, playerColor)
if playerColor == 'Black' then
if grimShow == false then
local options = Global.getTable('options')
local safetyExpired = Global.getVar('safetyExpired')
if options.safetyOn then
if safetyExpired then
Player['Black'].broadcast('Click again to reveal the grimoire.', {1,0,0})
Global.call('startSafetyCooldown')
else
showGrimoire()
end
else
showGrimoire()
end
else
hideGrimoire()
end
end
end
function onObjectLeaveScriptingZone(zone, object)
if zone.getGUID() == SCRIPTING_ZONE_GUID then
local pos = object.getPosition()
if pos[2] < 0 then
object.setPosition({pos[1], 1.3, pos[3]})
object.setLock(true)
Wait.time(function() object.setLock(false) end, 0.75)
end
end
end
function showGrimoire()
local scriptZone
grimShow = true
if objects.blackZone ~= nil then
objects.blackZone.setScale({0,0,0})
end
self.editButton({
index = 7,
label = 'Hide\nGrimoire',
tooltip = 'Click this to hide the grimoire.',
})
end
function hideGrimoire()
grimShow = false
if objects.blackZone ~= nil then
objects.blackZone.setScale(BLACK_ZONE.scale)
end
self.editButton({
index = 7,
label = 'Show\nGrimoire',
tooltip = 'Click this to show the grimoire.',
})
end
function reloadGrimoire()
if objects.blackZone ~= nil then
objects.blackZone = objects.blackZone.reload()
end
end
function inZone(obj, zone)
local zoneObjs = zone.getObjects()
for k,v in pairs(zoneObjs) do
if obj.getGUID() == v.getGUID() then
return true
end
end
return false
end
function inTable(string, table)
for k,v in pairs(table) do
if string == v then
return true
end
end
return false
end
function onScriptingButtonUp(index, playerColor)
if playerColor ~= 'Black' then
return
end
if index == 1 then
minusRot(_, 'Black')
elseif index == 2 then
toggleClockMovement(_, playerColor)
elseif index == 3 then
plusRot(_, 'Black')
elseif index == 5 then
if mode == 'Clock' then
toggleClockNom(_, playerColor)
elseif mode == 'Blind' then
blindfoldAll(_, playerColor)
else
muteAll(_, playerColor)
end
elseif index == 8 then
toggleModes(_, playerColor)
end
end
function setClockStyle(params)
if clockStyle == params.style then
return
end
local globalObjects = Global.getTable('objects')
clockStyle = params.style
objects.clock.setCustomObject({face = CLOCK_IMAGE_URLS[clockStyle].clock, back = CLOCK_IMAGE_URLS[clockStyle].clock})
if objects.secondHand.getScale()[1] ~= 0 then
objects.hourHand.setScale(CLOCK_HAND_SCALE[clockStyle].hour)
objects.minuteHand.setScale(CLOCK_HAND_SCALE[clockStyle].minute)
objects.secondHand.setScale(CLOCK_HAND_SCALE[clockStyle].second)
end
objects.hourHand.setCustomObject({image = CLOCK_IMAGE_URLS[clockStyle].hour, thickness = 0.1})
objects.hourHand = objects.hourHand.reload()
globalObjects.hourHand = objects.hourHand
objects.minuteHand.setCustomObject({image = CLOCK_IMAGE_URLS[clockStyle].minute, thickness = 0.1})
objects.minuteHand = objects.minuteHand.reload()
globalObjects.minuteHand = objects.minuteHand
objects.secondHand.setCustomObject({image = CLOCK_IMAGE_URLS[clockStyle].second, thickness = 0.1})
objects.secondHand = objects.secondHand.reload()
globalObjects.secondHand = objects.secondHand
Global.setTable('objects', globalObjects)
Wait.time(function()
objects.hourHand.interactable = false
objects.minuteHand.interactable = false
objects.secondHand.interactable = false
end, 1)
end
function refreshButtons()
self.clearButtons()
self.clearInputs()
local params = {function_owner = self, position = {0, 1, 0}, scale = UI_SCALE, width = 2700, height = 500, font_size = 400}
if mode == 'Clock' and objects.clock.getScale().x == 0 then
params.label = 'Show Clock'
params.click_function = 'toggleClockNom'
params.color = {40/255, 47/255, 85/255}
params.font_color = BUTTON_FONT_COLOR
elseif mode == 'Clock' and objects.clock.getScale().x ~= 0 then
params.label = 'Hide Clock'
params.click_function = 'toggleClockNom'
params.color = {1,0,0}
params.font_color = BUTTON_FONT_COLOR
elseif mode == 'Blind' and allBlind then
params.label = 'Unblindfold All'
params.click_function = 'blindfoldAll'
params.color = {1,0,0}
params.font_color = BUTTON_FONT_COLOR
elseif mode == 'Blind' and not allBlind then
params.label = 'Blindfold All'
params.click_function = 'blindfoldAll'
params.color = {40/255, 47/255, 85/255}
params.font_color = BUTTON_FONT_COLOR
elseif mode == 'Mute' and allMuted then
params.label = 'Unmute All'
params.click_function = 'muteAll'
params.color = {1,0,0}
params.font_color = BUTTON_FONT_COLOR
elseif mode == 'Mute' and not allMuted then
params.label = 'Mute All'
params.click_function = 'muteAll'
params.color = {40/255, 47/255, 85/255}
params.font_color = BUTTON_FONT_COLOR
end
self.createButton(params)
params = {click_function = 'toggleClockMovement', function_owner = self, position = {0, 1, 1.2}, width = 2700, height = 500, font_size = 400}
if objects.clock.getScale().x ~= 0 then
params.scale = UI_SCALE
else
params.scale = {0,0,0}
end
if rotating then
params.label = 'Stop Clock'
params.color = {1,0,0}
params.font_color = BUTTON_FONT_COLOR
else
params.label = 'Start Clock'
params.color = {40/255, 47/255, 85/255}
params.font_color = BUTTON_FONT_COLOR
end
self.createButton(params)
params = {input_function = 'setRotValue', function_owner = self, label = 'Rotation Value',
position = {0, 1, 0.6}, scale = UI_SCALE,
width = 1000, height = 500, font_size = 465, color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
tooltip = 'How fast the purple hand rotates\n(in degrees per second)', validation = 3, alignment = 3, value = rotationRate}
self.createInput(params)
params = {click_function = 'minusRot', function_owner = self, label = '-', color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
position = {-0.85, 1, 0.6}, scale = UI_SCALE, tooltip = 'Decrease clock speed by 6',
width = 500, height = 500, font_size = 400, alignment = 3}
self.createButton(params)
params = {click_function = 'plusRot', function_owner = self, label = '+', color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
position = {0.85, 1, 0.6}, scale = UI_SCALE, tooltip = 'Increase clock speed by 6',
width = 500, height = 500, font_size = 400, alignment = 3}
self.createButton(params)
params = {click_function = 'toggleModeClock', function_owner = self, color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
label = 'Clock\nMode', position = {-1, 1, -1.2}, scale = UI_SCALE,
width = 900, height = 500, font_size = 200, tooltip = 'Switch to Clock Mode'}
if mode == 'Clock' then
params.color = {40/255, 47/255, 85/255}
end
self.createButton(params)
params = {click_function = 'toggleModeBlind', function_owner = self, color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
label = 'Blindfold\nMode', position = {0, 1, -1.2}, scale = UI_SCALE,
width = 900, height = 500, font_size = 200, tooltip = 'Switch to Blindfold Mode'}
if mode == 'Blind' then
params.color = {40/255, 47/255, 85/255}
end
self.createButton(params)
params = {click_function = 'toggleModeMute', function_owner = self, color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR,
label = 'Mute\nMode', position = {1, 1, -1.2}, scale = UI_SCALE,
width = 900, height = 500, font_size = 200, tooltip = 'Switch to Mute Mode'}
if mode == 'Mute' then
params.color = {40/255, 47/255, 85/255}
end
self.createButton(params)
params = {click_function = 'toggleHiddenZones', function_owner = self, position = {-0.65, 1, -1.8}, scale = UI_SCALE,
color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR, width = 1200, height = 500, font_size = 200,}
if grimShow then
params.label = 'Hide\nGrimoire'
params.tooltip = 'Click this to hide the grimoire.'
else
params.label = 'Show\nGrimoire'
params.tooltip = 'Click this to show the grimoire.'
end
self.createButton(params)
params = {click_function = 'toggleClockExile', function_owner = self, position = {0.65, 1, -1.8}, scale = UI_SCALE,
color = BUTTON_COLOR, font_color = BUTTON_FONT_COLOR, width = 1200, height = 500, font_size = 200, tooltip = 'Show the clock for exiling a traveler.'}
if objects.clock.getScale().x == 0 then
params.label = 'Exile\nClock'
else
params.label = 'Hide\nClock'
end
self.createButton(params)
local tooltip, func
if mode == 'Clock' then
tooltip = 'Point the clock to '
func = 'pointTo'
elseif mode == 'Mute' then
tooltip = 'Mute '
func = 'mute'
elseif mode == 'Blind' then
tooltip = 'Blindfold player '
func = 'blindfold'
end
local startingVal = 0.3 - #colors * 0.3
for i, c in ipairs(colors) do
params = {click_function = func .. c, function_owner = self, label = ' ',
position = {startingVal + 0.6*(i-1), 1, -0.6}, scale = UI_SCALE,
width = 500, height = 500, font_size = 400,
color = c, tooltip = tooltip .. c}
if inTable(c, COLORS_EX) then
params.color = COLORS_EX_HEX[c]
end
self.createButton(params)
end
end