-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTool.ttslua
More file actions
1898 lines (1693 loc) · 65 KB
/
Copy pathTool.ttslua
File metadata and controls
1898 lines (1693 loc) · 65 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
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
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
SH Expansion Tool
Made by Sionar
--]]
------------------Constants
COLOR_TABLE = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink', 'Tan', 'Maroon'}
COLOR_BBC = {White = '[FFFFFF]', Brown = '[703A16]', Red = '[DA1917]', Orange = '[F3631C]', Yellow = '[E6E42B]', Green = '[30B22A]', Teal = '[20B09A]', Blue = '[1E87FF]', Purple = '[9F1FEF]', Pink = '[F46FCD]', Tan = '[D2B48C]', Maroon = '[800000]'}
DRAW_ZONE_GUID = '6463d3'
DISCARD_ZONE_GUID = 'b9bd6e'
EFFECT_ZONE_GUID = '374a16'
ABILITY_ZONE_GUID = 'eea120'
LIBERALPARTY_CARD_GUID = 'a73564'
FASCISTPARTY_CARD_GUID = 'e4d489'
PLAYER_BUTTON_POS_10P = {{-1.4,0.2,0.7}, {-1.4,0.2,1.1}, {-2.0,0.2,1.1}, {-2.0,0.2,0.7}, {-2,0.2,0.3}, {-2,0.2,-0.1}, {-2,0.2,-0.5}, {-1.4,0.2,-0.5}, {-1.4,0.2,-0.1}, {-1.4,0.2,0.3}}
TARGET_BUTTON_POS_10P = {{0.3,0.2,0.7}, {0.3,0.2,1.1}, {-0.3,0.2,1.1}, {-0.3,0.2,0.7}, {-0.3,0.2,0.3}, {-0.3,0.2,-0.1}, {-0.3,0.2,-0.5}, {0.3,0.2,-0.5}, {0.3,0.2,-0.1}, {0.3,0.2,0.3}}
PLAYER_BUTTON_POS_12P = {{-2.12,0.2,0.6},{-2.26,0.2,0.3},{-2.26,0.2,0},{-2.26,0.2,-0.3},{-2.12,0.2,-0.6},{-1.7,0.2,-0.6},{-1.28,0.2,-0.6},{-1.14,0.2,-0.3},{-1.14,0.2,0},{-1.14,0.2,0.3},{-1.28,0.2,0.6},{-1.7,0.2,0.6}}
TARGET_BUTTON_POS_12P = {{-0.42,0.2,0.6},{-0.56,0.2,0.3},{-0.56,0.2,0},{-0.56,0.2,-0.3},{-0.42,0.2,-0.6},{0,0.2,-0.6},{0.42,0.2,-0.6},{0.56,0.2,-0.3},{0.56,0.2,0},{0.56,0.2,0.3},{0.42,0.2,0.6},{0,0.2,0.6}}
GIVE_TOOL_BUTTON_POS = {{1,0.2,0.9}, {0,0.2,0.9}, {-1,0.2,0.9}, {-1.7,0.2,0.3}, {-1.7,0.2,-0.3}, {-1,0.2,-0.9}, {0,0.2,-0.9}, {1,0.2,-0.9}, {1.7,0.2,-0.3}, {1.7,0.2,0.3}}
MAROON_DRAW_POS = {-9, 1.5, -49}
TAN_DRAW_POS = {20.30, 1.5, -49}
GREY_PLAYABLE_COLORS = {'Tan', 'Maroon'}
------------------Variables
state = 0
player = ""
targSelected = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
numSelected = 0
drawNum = 1
option = 0
promOnly = true
gambleTable = {White = '', Brown = '', Red = '', Orange = '', Yellow = '', Green = '', Teal = '', Blue = '', Purple = '', Pink = '', Tan = '', Brown = '' }
efName = ''
------------------Load Save
function onLoad(saveString)
clearValues()
math.randomseed(os.time())
if not (saveString == '') then
local save = JSON.decode(saveString)
state = save['st']
promOnly = save['pr']
gambleTable = save['g'] or gambleTable
end
refreshButtons()
self.setDescription('v ' .. VERSION .. '\nMade by Sionar\nUse with SH Consolidator Edition workshop mod.')
local global_name = Global.getVar('MOD_NAME')
local started = Global.getVar('started')
if not started and global_name == 'Secret Hitler: CE' then
self.setLock(true)
local tempScale = self.getScale()[1]
self.scale(1/tempScale)
self.scale(5.8)
local pos = {forward = -13, right = 0, up = 3}
local rot = {x = 0, y = 180, z = 0}
giveObjectToPlayer(self, COLOR_TABLE[3], pos, rot)
end
end
function onSave()
local save = {}
save['st'] = state
save['pr'] = promOnly
save['g'] = gambleTable
local saveString = JSON.encode(save)
return saveString
end
------------------Main Functions
function decDraw()
if drawNum ~= 1 then
drawNum = drawNum - 1
end
drawMenu()
end
function incDraw()
drawNum = drawNum + 1
drawMenu()
end
function decAbDraw()
if drawNum ~= 1 then
drawNum = drawNum - 1
end
abDrawMenu()
end
function incAbDraw()
drawNum = drawNum + 1
abDrawMenu()
end
function piggyCall(params) --For calling ability draw from the Piggy card.
player = params.player
drawNum = 1
abDrawStart(_, player)
end
function abDrawStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local abilityDeck = getDeckFromZoneByGUID(ABILITY_ZONE_GUID)
if abilityDeck == nil then
broadcastToColor("ERROR: Ability deck not found.", playerColor, {1,0,0})
return
end
local pos1 = abilityDeck.getPosition()
local rotUp = {x = 0, y = 180, z = 0}
local rotDown = {x = 0, y = 180, z = 180}
local allObjs = getAllObjects()
local tmpObj
local card
local params = {index = 1}
abilityDeck.shuffle()
for i = 1, drawNum do
card = abilityDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, rotDown)
end
local broadcastString = colorString(player) .. " draws " .. drawNum
if drawNum == 1 then
broadcastString = broadcastString .. " ability from the ability deck."
else
broadcastString = broadcastString .. " abilities from the ability deck."
end
broadcastToAll(broadcastString, {1,1,1})
returnFunc()
end
end
function drawStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local drawDeck = getDeckFromZoneByGUID('6463d3')
if drawDeck == nil then
broadcastToColor("ERROR: Policy deck not found.", playerColor, {1,0,0})
return
end
Global.call('callFunction', {fcn = 'drawCards', params = {drawNum, player}})
if drawNum >= 6 or drawNum > drawDeck.getQuantity() then
startShufTimer()
end
returnFunc()
end
end
function sdStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
local lib, fas, random = 0, 0, 0
local inspectedRoles = {}
local players = Global.getTable('players')
local roles = Global.getTable('roles')
local numPlayers = #players
numPlayers = (numPlayers - numPlayers%2)/2
if numSelected < numPlayers then
broadcastToColor("ERROR: Not enough players selected", playerColor, {1,0,0})
return
elseif numSelected > numPlayers then
broadcastToColor("ERROR: Too many players selected", playerColor, {1,0,0})
return
end
if player == "" then
broadcastToColor("ERROR: Inspector not selected", playerColor, {1,0,0})
return
end
local broadcastString = colorString(player) .. " inspects "
for i = 1,12 do
if targSelected[i] == 1 then
broadcastString = broadcastString .. colorString(COLOR_TABLE[i]) .. " "
if roles[COLOR_TABLE[i]] == "liberal" then
table.insert(inspectedRoles, "liberal")
else
table.insert(inspectedRoles, "fascist")
end
end
end
random = math.random(1,numSelected)
table.remove(inspectedRoles, random)
for i = 1, numSelected-1 do
if inspectedRoles[i] == "liberal" then
lib = lib + 1
else
fas = fas + 1
end
end
broadcastToAll(broadcastString, {1,1,1})
broadcastToColor12P("You found " .. lib .. " liberals and " .. fas .. " fascists.", player, {1,1,1})
returnFunc()
end
end
function spyStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
Global.call('removeInspect')
Global.call('callFunction', {fcn = 'createInspectButtons', params = {player}})
local options = Global.getTable('options')
if options.autoNotate then
Global.call('callFunction', {fcn = 'notateInfo', params = {player, 'inspects', '', '', true}})
end
returnFunc()
end
end
function inspectStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected", playerColor, {1,0,0})
return
end
if numSelected == 0 then
broadcastToColor("ERROR: Target not selected", playerColor, {1,0,0})
return
end
local roles = Global.getTable('roles')
local broadcastString = colorString(player) .. " inspects "
local inspectMessage
for i = 1,12 do
if targSelected[i] == 1 then
broadcastString = broadcastString .. colorString(COLOR_TABLE[i]) .. " "
if roles[COLOR_TABLE[i]] == "liberal" then
inspectMessage = colorString(COLOR_TABLE[i]) .. " is a Liberal!"
broadcastToColor12P(inspectMessage, player, {0,0,1})
else
inspectMessage = colorString(COLOR_TABLE[i]) .. " is a Fascist!"
broadcastToColor12P(inspectMessage, player, {1,0,0})
end
end
end
broadcastToAll(broadcastString, {1,1,1})
returnFunc()
end
end
function spelunStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local tmpDeck = getDeckFromZoneByGUID(DISCARD_ZONE_GUID)
if tmpDeck == nil then
broadcastToColor("ERROR: Discard pile not found.", playerColor, {1,0,0})
return
end
local params = {index = option}
local card = tmpDeck.takeObject(params)
local delta = {forward = 0, right = 0, up = 0}
if player == 'Tan' or player == 'Maroon' then
delta = {forward = 2.66, right = -9, up = 0}
end
giveObjectToPlayer(card, player, delta, {x = 0, y = 180, z = 180})
local broadcastString
if option == 0 then
broadcastString = player .. " looks at the top card of the discard pile"
else
broadcastString = player .. " looks at the second card of the discard pile"
end
broadcastToAll(broadcastString, {1,1,1})
returnFunc()
end
end
function gambleStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
local abilityDeck = getDeckFromZoneByGUID(ABILITY_ZONE_GUID)
if drawDeck == nil then
broadcastToColor("ERROR: Policy deck not found.", playerColor, {1,0,0})
return
end
if abilityDeck == nil then
broadcastToColor("ERROR: Ability deck not found.", playerColor, {1,0,0})
return
end
startLuaCoroutine(self, 'gambleCoroutine')
mainMenu()
end
end
function gambleCoroutine()
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
local deckTable = drawDeck.getObjects()
local abilityDeck = getDeckFromZoneByGUID(ABILITY_ZONE_GUID)
local pos1 = abilityDeck.getPosition()
local rotUp = {x = 0, y = 180, z = 0}
local rotDown = {x = 0, y = 180, z = 180}
local broadcastString = colorString(player) .. " bet on a "
local allObjs = getAllObjects()
local tmpObj
local cardMemory = false
local tmpPos, tmpRot, params, card
for _, tmpObj in ipairs(allObjs) do
if tmpObj.getName() ~= '' and tmpObj.getName() == gambleTable[player] then
cardMemory = true
tmpPos = tmpObj.getPosition()
tmpRot = tmpObj.getRotation()
tmpObj.setPositionSmooth(pos1)
tmpObj.setRotationSmooth(rotDown)
sleep(2)
end
end
abilityDeck.shuffle()
if option == 1 then
broadcastString = broadcastString .. "Liberal policy card and "
else
broadcastString = broadcastString .. "Fascist policy card and "
end
local payload = {}
payload.steam_id = Player[player].steam_id
if (deckTable[1].description == "Liberal Policy" and option == 1) or (deckTable[1].description == "Fascist Policy" and option == 0) then
broadcastString = broadcastString .. "won!"
if cardMemory then
params = {index = 1, position = tmpPos, rotation = tmpRot}
card = abilityDeck.takeObject(params)
else
params = {index = 1}
card = abilityDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, rotDown)
end
gambleTable[player] = card.getName()
payload.won = 'true'
payload.version = 2
WebRequest.post('https://shstats.teliot.dev/gamble.php', payload, function(req)
if req.is_done and not req.is_error then
local objs = getAllObjects()
for k,v in pairs(objs) do
if string.match(v.getName(), 'Scoreboard Web') then
local stats = v.getTable('stats')
stats[Player[player].steam_id].gambler_attempts = stats[Player[player].steam_id].gambler_attempts + 1
stats[Player[player].steam_id].gambler_wins = stats[Player[player].steam_id].gambler_wins + 1
v.setTable('stats', stats)
local state = v.getVar('state')
if state == 1 then
v.call('miscMenu')
end
end
end
end
end)
else
broadcastString = broadcastString .. "lost!"
WebRequest.post('https://shstats.teliot.dev/gamble.php?id=' .. Player[player].steam_id .. '&result=lose')
payload.won = 'false'
WebRequest.post('https://shstats.teliot.dev/gamble.php', payload, function(req)
if req.is_done and not req.is_error then
local objs = getAllObjects()
for k,v in pairs(objs) do
if string.match(v.getName(), 'Scoreboard Web') then
local stats = v.getTable('stats')
stats[Player[player].steam_id].gambler_attempts = stats[Player[player].steam_id].gambler_attempts + 1
v.setTable('stats', stats)
local state = v.getVar('state')
if state == 1 then
v.call('miscMenu')
end
end
end
end
end)
end
broadcastToAll(broadcastString, {1,1,1})
local pos2 = drawDeck.getPosition()
local params = {index = 0}
local card = drawDeck.takeObject(params)
card.setPosition({pos2['x'], pos2['y']+1, pos2['z']})
card.setRotationSmooth({rotUp['x'], rotUp['y'], rotUp['z']})
sleep(3)
card.setRotationSmooth({rotDown['x'], rotDown['y'], rotDown['z']})
sleep(1)
drawDeck.shuffle()
clearValues()
return 1
end
function fisherStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local discDeck = getDeckFromZoneByGUID(DISCARD_ZONE_GUID)
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
local ph
if discDeck == nil then
broadcastToColor("ERROR: Discard pile not found.", playerColor, {1,0,0})
return
end
if discDeck.getQuantity() < 4 then
broadcastToColor("ERROR: Not enough cards in the discard pile.", playerColor, {1,0,0})
return
end
discDeck.shuffle()
if player ~= 'Maroon' and player ~= 'Tan' then
discDeck.dealToColor(3, player)
else
if player == 'Maroon' then
ph = MAROON_DRAW_POS
else
ph = TAN_DRAW_POS
end
function fishCoroutine()
sleep(0.5)
local takeParam = {}
takeParam.position = ph
for i = 1, 3 do
discDeck.takeObject(takeParam)
takeParam.position[2] = takeParam.position[2] + 0.01
sleep(0.1)
end
return 1
end
startLuaCoroutine(self, 'fishCoroutine')
end
local broadcastString = colorString(player) .. " draws 3 cards from the discard pile."
broadcastToAll(broadcastString, {1,1,1})
startShufTimer()
returnFunc()
end
end
function martyrStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
if drawDeck == nil then
broadcastToColor("ERROR: Policy deck not found.", playerColor, {1,0,0})
return
end
reshuffle()
Wait.time(martyrStart2, 1)
end
end
function martyrStart2()
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
local deckTable = drawDeck.getObjects()
local size = drawDeck.getQuantity()
local found = 0
found = getIndex(option, size, deckTable, "Liberal Policy", "Fascist Policy")
local broadcastString
if option == 0 then
broadcastString = colorString(player) .. " played a Liberal policy card and died!"
else
broadcastString = colorString(player) .. " played a Fascist policy card and died!"
end
broadcastToAll(broadcastString, {1,1,1})
local params = {index = found-1}
local card = drawDeck.takeObject(params)
local delta = {forward = 0, right = 0, up = 0}
if player == 'Tan' or player == 'Maroon' then
delta = {forward = 2.66, right = -9, up = 0}
end
giveObjectToPlayer(card, player, delta, {x = 0, y = 180, z = 180})
reshuffle()
Global.setVar('lastPres', player)
Global.setVar('lastChan', player)
--[[
local playerStat = Global.getTable('playerStatus')
playerStat[player] = 5
Global.setTable('playerStatus', playerStat)
Global.call('refreshStatusButtons')
--]]
returnFunc()
end
function dervishStart(clickedButton, playerColor)
if numSelected == 0 then
broadcastToColor("ERROR: Target not selected", playerColor, {1,0,0})
return
end
local targetColor
local found = false
for i,v in ipairs(targSelected) do
if v == 1 then
targetColor = COLOR_TABLE[i]
end
end
local player1SteamId = Player[player].steam_id
local player2SteamId = Player[targetColor].steam_id
local roles = Global.getTable('roles')
local hitler = Global.getTable('hitler')
local fascists = Global.getTable('fascists')
if roles[player] == nil or roles[targetColor] == nil then
broadcastToColor("ERROR: At least one of the seats you selected is not playing.", playerColor, {1,0,0})
return
end
Player[player].changeColor('Grey')
Player[targetColor].changeColor('Grey')
if roles[player] == 'hitler' then
hitler[1] = targetColor
end
if roles[targetColor] == 'hitler' then
hitler[1] = player
end
if roles[player] ~= roles[targetColor] then
if roles[player] == 'fascist' then
for i,v in ipairs(fascists) do
if v == player then
fascists[i] = targetColor
end
end
end
if roles[targetColor] == 'fascist' then
for i,v in ipairs(fascists) do
if v == targetColor then
fascists[i] = player
end
end
end
roles[player], roles[targetColor] = roles[targetColor], roles[player]
Global.setTable('roles', roles)
Global.setTable('hitler', hitler)
Global.setTable('fascists', fascists)
end
Global.call('refreshUI')
for k,v in pairs(Player.getPlayers()) do
if player1SteamId ~= nil and v.steam_id == player1SteamId then
v.changeColor(targetColor)
end
if player2SteamId ~= nil and v.steam_id == player2SteamId then
v.changeColor(player)
end
end
swapObjects(player, targetColor)
swapNotes(player, targetColor)
returnFunc()
end
function swapObjects(color1, color2)
local HIDDEN_ZONE_GUIDS = Global.getTable('HIDDEN_ZONE_GUIDS')
local HAND_GUIDS = {White = '607c55', Brown = '502823', Red = '0059ce', Orange = 'f9fa27', Yellow = '0142f7', Green = 'e66061', Teal = 'e1eb39', Blue = '64f06e', Purple = 'd947f6', Pink = '2ee8f0'}
local hand1Pos = getObjectFromGUID(HAND_GUIDS[color1]).getPosition()
local hand2Pos = getObjectFromGUID(HAND_GUIDS[color2]).getPosition()
local hand1Objects = getObjectFromGUID(HIDDEN_ZONE_GUIDS[color1]).getObjects()
local hand2Objects = getObjectFromGUID(HIDDEN_ZONE_GUIDS[color2]).getObjects()
local rot
for k,v in pairs(hand1Objects) do
if not string.match(v.getDescription(), 'Ja Card') and not string.match(v.getDescription(), 'Nein Card') then
rot = v.getRotation()
rot.z = 180
v.setRotation(rot)
v.setPosition(hand2Pos)
end
end
for k,v in pairs(hand2Objects) do
if not string.match(v.getDescription(), 'Ja Card') and not string.match(v.getDescription(), 'Nein Card') then
rot = v.getRotation()
rot.z = 180
v.setRotation(rot)
v.setPosition(hand1Pos)
end
end
end
function swapNotes(color1, color2)
local noteTakerNotes = Global.getTable('noteTakerNotes')
for i,v in ipairs(noteTakerNotes) do
if v.color1 == color1 then
noteTakerNotes[i].color1 = color2
elseif v.color1 == color2 then
noteTakerNotes[i].color1 = color1
end
if v.color2 == color1 then
noteTakerNotes[i].color2 = color2
elseif v.color2 == color2 then
noteTakerNotes[i].color2 = color1
end
end
Global.setTable('noteTakerNotes', noteTakerNotes)
Global.call('refreshNotes')
end
function startShufTimer()
Wait.time(shufCheck, 1)
end
function shufCheck()
if Global.call('allPolicyCardsKnown') then
Wait.time(shufStart, 0.3)
else
startShufTimer()
end
end
function shufStart()
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
if drawDeck == nil then
broadcastToColor("ERROR: Policy deck not found.", playerColor, {1,0,0})
return
end
drawDeck.shuffle()
end
function passedStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
Global.setVar('votePassed', true)
Global.setVar('blockDraw', false)
end
end
function reshufStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
reshuffle()
returnFunc()
end
end
function givepStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if numSelected == 0 then
broadcastToColor("ERROR: Target not selected", playerColor, {1,0,0})
return
end
startLuaCoroutine(self, 'givePCoroutine')
end
end
function givePCoroutine()
local roles = Global.getTable('roles')
local broadcastString
local card, cardClone
local params = {}
for i = 1,12 do
if targSelected[i] == 1 then
if roles[COLOR_TABLE[i]] == "liberal" then
broadcastString = colorString(COLOR_TABLE[i]) .. " is a Liberal!"
broadcastToAll(broadcastString, {0,0,1})
card = getObjectFromGUID(LIBERALPARTY_CARD_GUID)
else
broadcastString = colorString(COLOR_TABLE[i]) .. " is a Fascist!"
broadcastToAll(broadcastString, {1,0,0})
card = getObjectFromGUID(FASCISTPARTY_CARD_GUID)
end
params.position = {0, 100, 0}
cardClone = card.clone(params)
cardClone.setLock(false)
cardClone.interactable = true
giveObjectToPlayer(cardClone, COLOR_TABLE[i], {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 0})
sleep(0.1)
end
end
returnFunc()
return 1
end
function giveEfStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
local effectDeck = getDeckFromZoneByGUID(EFFECT_ZONE_GUID)
if player == "" then
broadcastToColor("ERROR: Player not selected.", playerColor, {1,0,0})
return
end
if effectDeck == nil then
broadcastToColor("ERROR: Effect deck not found.", playerColor, {1,0,0})
return
end
startLuaCoroutine(self, 'giveEFCoroutine')
end
end
function giveEFCoroutine()
local tab = self.getInputs()
local effectDeck = getDeckFromZoneByGUID(EFFECT_ZONE_GUID)
local deckTable = effectDeck.getObjects()
local size = effectDeck.getQuantity()
local found = 0
local params = {}
local card
local tmpString, tmpStartIndex, tmpEndIndex
if option == 0 then
for i = 1,size do
tmpString = deckTable[i].name
if string.match(tmpString, 'Drink 1') then
found = 1
break
elseif string.match(tmpString, 'Drink 2') then
found = 2
break
end
end
if found == 0 then
broadcastToAll('ERROR: Poisoner effect cards not found in effects deck.', {1,0,0})
clearValues()
mainMenu()
return 1
end
for i = size,1,-1 do
tmpString = deckTable[i].name
if string.match(tmpString, 'Drink ' .. found) then
params = {index = i-1}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 180})
sleep(0.1)
end
end
broadcastToAll('The Poisoner effect cards have been dealt to ' .. colorString(player) .. '.', {1,1,1})
elseif option == 1 then
for i = 1,size do
tmpString = deckTable[i].name
if string.match(tmpString, 'Inspected 1') then
found = 1
break
elseif string.match(tmpString,'Inspected 2') then
found = 2
break
end
end
if found == 0 then
broadcastToAll('ERROR: Inspected effect cards not found in effects deck.', {1,0,0})
clearValues()
mainMenu()
return 1
end
for i = size,1,-1 do
tmpString = deckTable[i].name
if string.match(tmpString, 'Inspected ' .. found) then
params = {index = i-1}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 0})
sleep(0.1)
end
end
broadcastToAll('The Detective effect cards have been dealt to ' .. colorString(player) .. '.', {1,1,1})
elseif option == 2 then
for i = 1,size do
tmpString = deckTable[i].name
if string.match(tmpString, 'Artifact') then
found = 1
break
end
end
if found == 0 then
broadcastToAll('ERROR: Artifact effect cards not found in effects deck.', {1,0,0})
clearValues()
mainMenu()
return 1
end
for i = size,1,-1 do
tmpString = deckTable[i].name
if string.match(tmpString, 'Artifact') then
params = {index = i-1}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 180})
sleep(0.1)
end
end
broadcastToAll('The Artifact effect cards have been dealt to ' .. colorString(player) .. '.', {1,1,1})
elseif option == 3 then
for i = 1,size do
tmpString = deckTable[i].name
if string.match(tmpString, 'Life') then
found = 1
break
end
end
if found == 0 then
broadcastToAll('ERROR: Desperado cards not found in effects deck.', {1,0,0})
clearValues()
mainMenu()
return 1
end
for i = size,1,-1 do
tmpString = deckTable[i].name
if string.match(tmpString, 'Life') or string.match(tmpString, 'Death') and not string.match(tmpString, 'Sentence') then
params = {index = i-1}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 180})
sleep(0.1)
end
end
broadcastToAll('The Desperado cards have been dealt to ' .. colorString(player) .. '.', {1,1,1})
elseif option == 4 then
for i = 1,size do
tmpString = deckTable[i].name
if string.match(tmpString, 'Potion') then
found = 1
break
end
end
if found == 0 then
broadcastToAll('ERROR: Potion effect cards not found in effects deck.', {1,0,0})
clearValues()
mainMenu()
return 1
end
for i = size,1,-1 do
tmpString = deckTable[i].name
if string.match(tmpString, 'Potion') then
params = {index = i-1}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 180})
sleep(0.1)
end
end
broadcastToAll('The Potion effect cards have been dealt to ' .. colorString(player) .. '.', {1,1,1})
else
for i = size,1,-1 do
tmpString = deckTable[i].name
if tmpString == efName then
found = i
params = {index = i-1, flip = true}
card = effectDeck.takeObject(params)
giveObjectToPlayer(card, player, {forward = 16.5, right = 0, up = 0}, {x = 0, y = 180, z = 0})
broadcastToAll('The ' .. tmpString .. ' [FFFFFF]effect card has been dealt to ' .. colorString(player) .. '.', {1,1,1})
break
end
end
if found == 0 then
broadcastToAll('ERROR: Effect card with name ' .. efName .. ' not found in effects deck.', {1,0,0})
end
end
efName = ''
clearValues()
mainMenu()
return 1
end
function randStart(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
local targs = {}
local randNum, temp, colorString
local broadcastString = 'Random order: '
for i = 1, 12 do
if targSelected[i] == 1 then
colorString = COLOR_BBC[COLOR_TABLE[i]] .. COLOR_TABLE[i]
table.insert(targs, colorString)
end
end
for i = #targs, 1, -1 do
randNum = math.random(1, i)
temp = targs[randNum]
targs[randNum] = targs[i]
targs[i] = temp
end
for i = 1, #targs do
broadcastString = broadcastString .. targs[i] .. ' '
end
broadcastToAll(broadcastString, {1,1,1})
clearValues()
mainMenu()
end
end
function giveTool(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
self.setLock(true)
local tempScale = self.getScale()[1]
self.scale(1/tempScale)
self.scale(5.8)
local pos = {forward = -13, right = 0, up = 3}
local rot = {x = 0, y = 180, z = 0}
local options = Global.getTable('options')
if options.zoneType ~= 6 then
if COLOR_TABLE[index] == 'Purple' or COLOR_TABLE[index] == 'Orange' then
pos['right'] = 5
elseif COLOR_TABLE[index] == 'Pink' or COLOR_TABLE[index] == 'Yellow' then
pos['right'] = -5
end
end
giveObjectToPlayer(self, COLOR_TABLE[index], pos, rot)
returnFunc()
end
end
for k = 1,10 do
_G['giveTool' .. k] = function(obj, col)
giveTool(obj, col, k)
end
end
function promStart(clickedButton, playerColor)
if Player[playerColor].admin then
if promOnly == true then
promOnly = false
broadcastToAll("Expansion tool access has been granted to all users", {1,1,1})
else
promOnly = true
broadcastToAll("Expansion tool access has been granted to promoted users only", {1,1,1})
end
end
mainMenu()
end
function lockStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
lock()
end
end
function returnFunc()
state = 0
clearValues()
mainMenu()
end
function reshuffle()
local pos
local tmpDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
if tmpDeck then
pos = tmpDeck.getPosition()
else
local tmpZone = getObjectFromGUID(DRAW_ZONE_GUID)
pos = tmpZone.getPosition()
end
local discardDeck = getDeckFromZoneByGUID(DISCARD_ZONE_GUID)
if discardDeck == nil then
tmpZone = getObjectFromGUID(DISCARD_ZONE_GUID)
local tab = tmpZone.getObjects()
if tab[2] ~= nil then
tab[2].setPositionSmooth({pos['x'], pos['y'], pos['z']}, false, true)
end
end
if discardDeck ~= nil then
discardDeck.setPositionSmooth({pos['x'], pos['y'], pos['z']}, false, true)
end
startLuaCoroutine(self, 'shuffleCoroutine')
broadcastToAll('Deck reshuffled', {1,1,1})
end
function shuffleCoroutine()
sleep(1)
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
drawDeck.shuffle()
return 1
end
function lock()
local abilityDeck = getDeckFromZoneByGUID(ABILITY_ZONE_GUID)
local effectDeck = getDeckFromZoneByGUID(EFFECT_ZONE_GUID)
if abilityDeck == nil then
broadcastToColor("ERROR: Ability deck not found", playerColor, {1,0,0})
return
end
if abilityDeck.interactable == false then
broadcastToAll("The ability deck has been unlocked", {1,1,1})
else
broadcastToAll("The ability deck has been locked", {1,1,1})
end
abilityDeck.interactable = not abilityDeck.interactable
effectDeck.interactable = not effectDeck.interactable
mainMenu()
end
function opt(clickedButton, playerColor, index)