-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTool.ttslua
More file actions
1383 lines (1223 loc) · 46.1 KB
/
Tool.ttslua
File metadata and controls
1383 lines (1223 loc) · 46.1 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'}
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.1,0.7}, {-1.4,0.1,1.1}, {-2.0,0.1,1.1}, {-2.0,0.1,0.7}, {-2,0.1,0.3}, {-2,0.1,-0.1}, {-2,0.1,-0.5}, {-1.4,0.1,-0.5}, {-1.4,0.1,-0.1}, {-1.4,0.1,0.3}}
TARGET_BUTTON_POS_10P = {{0.3,0.1,0.7}, {0.3,0.1,1.1}, {-0.3,0.1,1.1}, {-0.3,0.1,0.7}, {-0.3,0.1,0.3}, {-0.3,0.1,-0.1}, {-0.3,0.1,-0.5}, {0.3,0.1,-0.5}, {0.3,0.1,-0.1}, {0.3,0.1,0.3}}
PLAYER_BUTTON_POS_12P = {{-2.12,0.1,0.6},{-2.26,0.1,0.3},{-2.26,0.1,0},{-2.26,0.1,-0.3},{-2.12,0.1,-0.6},{-1.7,0.1,-0.6},{-1.28,0.1,-0.6},{-1.14,0.1,-0.3},{-1.14,0.1,0},{-1.14,0.1,0.3},{-1.28,0.1,0.6},{-1.7,0.1,0.6}}
TARGET_BUTTON_POS_12P = {{-0.42,0.1,0.6},{-0.56,0.1,0.3},{-0.56,0.1,0},{-0.56,0.1,-0.3},{-0.42,0.1,-0.6},{0,0.1,-0.6},{0.42,0.1,-0.6},{0.56,0.1,-0.3},{0.56,0.1,0},{0.56,0.1,0.3},{0.42,0.1,0.6},{0,0.1,0.6}}
GIVE_TOOL_BUTTON_POS = {{1,0.1,0.9}, {0,0.1,0.9}, {-1,0.1,0.9}, {-1.7,0.1,0.3}, {-1.7,0.1,-0.3}, {-1,0.1,-0.9}, {0,0.1,-0.9}, {1,0.1,-0.9}, {1.7,0.1,-0.3}, {1.7,0.1,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
last_gambled = "none"
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']
last_gambled = save['l']
end
refreshButtons()
self.setDescription('v ' .. VERSION .. '\nMade by Sionar\nUse with SH Consolidator Edition workshop mod.')
end
function onSave()
local save = {}
save['st'] = state
save['pr'] = promOnly
save['l'] = last_gambled
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 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 = player .. " inspects "
for i = 1,12 do
if targSelected[i] == 1 then
broadcastString = broadcastString .. 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 = player .. " inspects "
local inspectMessage
for i = 1,12 do
if targSelected[i] == 1 then
broadcastString = broadcastString .. COLOR_TABLE[i] .. " "
if roles[COLOR_TABLE[i]] == "liberal" then
inspectMessage = COLOR_TABLE[i] .. " is a Liberal!"
broadcastToColor12P(inspectMessage, player, {0,0,1})
else
inspectMessage = 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 = player.." bet on a "
local allObjs = getAllObjects()
local tmpObj
local gambleResult
for _, tmpObj in ipairs(allObjs) do
tmpPos = tmpObj.getPosition()
if tmpObj.getName() == last_gambled and tmpObj.getName() ~= "" and tmpPos['x'] >= pos1['x'] - 15 and tmpPos['x'] <= pos1['x'] and tmpPos['z'] >= pos1['z'] - 8 and tmpPos['z'] <= pos1['z'] + 8 then
tmpObj.setRotationSmooth(rotDown)
tmpObj.setPositionSmooth(pos1)
sleep(0.5)
end
end
abilityDeck.shuffle()
if option == 1 then
broadcastString = broadcastString .. "Liberal policy card and "
else
broadcastString = broadcastString .. "Fascist policy card and "
end
if (deckTable[1].description == "Liberal Policy" and option == 1) or (deckTable[1].description == "Fascist Policy" and option == 0) then
broadcastString = broadcastString .. "won!"
local params = {index = 1}
local card = abilityDeck.takeObject(params)
card.setPositionSmooth({pos1['x'] - 5, pos1['y'], pos1['z']})
card.setRotationSmooth({rotDown['x'], rotDown['y'], rotDown['z']})
last_gambled = card.getName()
gambleResult = 'w'
else
broadcastString = broadcastString .. "lost!"
gambleResult = 'l'
end
---Scoreboard code
local tab = getAllObjects()
for _, v in pairs(tab) do
if string.match(v.getName(), "Scoreboard") then
tmpObj = v
break
end
end
if tmpObj ~= nil then
tmpObj.call('recGamble', {player, gambleResult})
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 = 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()
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 = player .. " played a Liberal policy card and died!"
else
broadcastString = 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
end
function startShufTimer()
Timer.destroy('shufTimer')
Timer.create({
identifier = 'shufTimer',
function_name = 'shufCheck',
delay = 1,
repetitions = 1,
})
end
function shufCheck()
if Global.call('allPolicyCardsKnown') then
startLuaCoroutine(self, 'shufDelayed')
else
startShufTimer()
end
end
function shufDelayed()
sleep(0.3)
shufStart()
return 1
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 = COLOR_TABLE[i] .. " is a Liberal!"
broadcastToAll(broadcastString, {0,0,1})
card = getObjectFromGUID(LIBERALPARTY_CARD_GUID)
else
broadcastString = 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
if option == 0 then
for i = 1,size do
if string.match(deckTable[i].nickname, 'Poisoned Drink 1') then
found = 1
break
elseif string.match(deckTable[i].nickname, 'Poisoned 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
if string.match(deckTable[i].nickname, 'Poisoned Drink ' .. found) or string.match(deckTable[i].nickname, 'Water ' .. 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 ' .. player .. '.', {1,1,1})
elseif option == 1 then
for i = 1,size do
if string.match(deckTable[i].nickname, 'Inspected 1') then
found = 1
break
elseif string.match(deckTable[i].nickname,'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
if string.match(deckTable[i].nickname, '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 ' .. player .. '.', {1,1,1})
elseif option == 2 then
for i = 1,size do
if string.match(deckTable[i].nickname, '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
if string.match(deckTable[i].nickname, '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 ' .. player .. '.', {1,1,1})
else
for i = size,1,-1 do
if deckTable[i].nickname == efName or string.match(string.lower(deckTable[i].nickname), string.lower(tab[1].value)) 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 ' .. deckTable[i].nickname .. ' [FFFFFF]effect card has been dealt to ' .. 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 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(6.1)
local pos = {forward = -13, right = 0, up = 1}
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 opt0() option = 0 refreshButtons() end
function opt1() option = 1 refreshButtons() end
function opt2() option = 2 refreshButtons() end
function getIndex(flag, size, table, string1, string2)
for i = 1,size,1 do
if flag == 0 then
if table[i].description == string1 then
return i
end
else
if table[i].description == string2 then
return i
end
end
end
return -1
end
function sleep(numSeconds)
local t0 = os.clock()
while os.clock() - t0 <= numSeconds do
coroutine.yield(0)
end
end
function giveObjectToPlayer(object, playerColor, posAdd, rotAdd, ...)
local pos
local rot
local vForward
local vRight
local vUp
if playerColor == 'Maroon' or playerColor == 'Tan' then
local greyPlayerHandGuids = Global.getTable('greyPlayerHandGuids')
local ph = getObjectFromGUID(greyPlayerHandGuids[playerColor])
if ph then
pos = ph.getPosition()
pos = {x = pos['x'], y = pos['y'], z = pos['z'] - 2.26}
rot = ph.getRotation()
vForward = ph.getTransformForward()
vRight = ph.getTransformRight()
vUp = ph.getTransformUp()
end
else
local ph = Player[playerColor].getPlayerHand();
if ph then
pos = {x = ph['pos_x'], y = ph['pos_y'], z = ph['pos_z']}
rot = {x = ph['rot_x'], y = ph['rot_y'], z = ph['rot_z']}
vForward = {x = ph['trigger_forward_x'], y = ph['trigger_forward_y'], z = ph['trigger_forward_z']}
vRight = {x = ph['trigger_right_x'], y = ph['trigger_right_y'], z = ph['trigger_right_z']}
vUp = {x = ph['trigger_up_x'], y = ph['trigger_up_y'], z = ph['trigger_up_z']}
end
end
if pos then
if rotAdd['exactRot'] then
object.setRotationSmooth({rotAdd['x'], rotAdd['y'], rotAdd['z']}, ...)
else
object.setRotationSmooth({rot['x'] + rotAdd['x'], rot['y'] + rotAdd['y'], rot['z'] + rotAdd['z']}, ...)
end
if posAdd['forceHeight'] then
object.setPositionSmooth({pos['x'] + vForward['x'] * posAdd['forward'] + vRight['x'] * posAdd['right'] + vUp['x'] * posAdd['up'],
posAdd['forceHeight'],
pos['z'] + vForward['z'] * posAdd['forward'] + vRight['z'] * posAdd['right'] + vUp['z'] * posAdd['up']}, ...)
else
object.setPositionSmooth({pos['x'] + vForward['x'] * posAdd['forward'] + vRight['x'] * posAdd['right'] + vUp['x'] * posAdd['up'],
pos['y'] + vForward['y'] * posAdd['forward'] + vRight['y'] * posAdd['right'] + vUp['y'] * posAdd['up'],
pos['z'] + vForward['z'] * posAdd['forward'] + vRight['z'] * posAdd['right'] + vUp['z'] * posAdd['up']}, ...)
end
end
end
function inTable(tableIn, valueIn)
local value
if tableIn then
for _, value in pairs(tableIn) do
if value == valueIn then
return true
end
end
end
return false
end
function getDeckFromZoneByGUID(guidIn)
local deck = nil
local deck_ct = 0
local zone = getObjectFromGUID(guidIn)
local object
if zone then
local inZone = zone.getObjects()
for _, object in ipairs(inZone) do
if object.name == 'Card' then
deck_ct = 2
elseif object.name == 'Deck' then
deck = object
deck_ct = deck_ct + 1
elseif object.name == 'DeckCustom' then
deck = object
deck_ct = deck_ct + 1
end
end
end
if deck_ct == 1 then
return deck
end
return nil
end
function RGB(color)
if color == 'Tan' then
return {r = 210/255, g = 180/255, b = 140/255}
elseif color == 'Maroon' then
return {r = 128/255, g = 0/255, b = 0/255}
else
return stringColorToRGB(color)
end
end
function greyPlayer(color)
if type(color) == 'table' then
color = color[1]
end
if inTable(GREY_PLAYABLE_COLORS, color) then
return true
else
return false
end
end
function getPlayerObj(color)
if greyPlayer(color) then
local playerFound = nil
steamId = greyPlayerSteamIds[color]
for _, player in ipairs(Player.getSpectators()) do
if steamId == player.steam_id then
playerFound = player
break
end
end
return playerFound
else
return Player[color]
end
end
function broadcastToColor12P(message, playerColor, messageColor)
local player = getPlayerObj(playerColor)
player.broadcast(message, messageColor)
end
------------------User Interface
function nulFunc()
end
function mainMenu()
self.clearButtons()
self.clearInputs()
local buttonParam = {click_function = 'drawMenu', label = "Draw", color = {1,1,1}, function_owner = self,
position = {-1.7,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'sdMenu', label = "Detective", color = {1,1,1}, function_owner = self,
position = {-1.7,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'spyMenu', label = "Spy", color = {1,1,1}, function_owner = self,
position = {-1.7,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'inspMenu', label = "Inspect", color = {1,1,1}, function_owner = self,
position = {-1.7,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'spelunMenu', label = "Spelunker", color = {1,1,1}, function_owner = self,
position = {-0.575,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'gambleMenu', label = "Gambler", color = {1,1,1}, function_owner = self,
position = {-0.575,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'fisherMenu', label = "Fisherman", color = {1,1,1}, function_owner = self,
position = {-0.575,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'martyrMenu', label = "Martyr", color = {1,1,1}, function_owner = self,
position = {-0.575,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'shufStart', label = "Shuffle\nDeck", color = {1,1,1}, function_owner = self,
position = {0.575,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'passedStart', label = "Vote\nPassed", color = {1,1,1}, function_owner = self,
position = {0.575,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'reshufMenu', label = "Reshuffle", color = {1,1,1}, function_owner = self,
position = {0.575,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'givepMenu', label = "Give\nParty Card", color = {1,1,1}, function_owner = self,
position = {0.575,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'givetMenu', label = "Give\nTool to", color = {1,1,1}, function_owner = self,
position = {1.7,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'promStart', color = {1,1,1}, function_owner = self,
position = {1.7,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 70}
if promOnly == false then buttonParam.label = "Tool Access:\nAll Players"
else buttonParam.label = "Tool Access:\nPromoted Only"
end
self.createButton(buttonParam)
local buttonParam = {click_function = 'lockStart', label = "Toggle Lock\nDecks", color = {1,1,1}, function_owner = self,
position = {1.7,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 70}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveEfMenu', label = "Deal\nEffect Cards", color = {1,1,1}, function_owner = self,
position = {1.7,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 70}
self.createButton(buttonParam)
end
function drawMenu()
self.clearButtons()
self.clearInputs()
state = 1
local buttonParam = {click_function = 'nulFunc', label = "Draw", color = {0,0,0,1}, font_color = stringColorToRGB('White'), function_owner = self,
position = {0,0.1,-1}, rotation = {0,0,0}, width = 0, height = 0, font_size = 150}
self.createButton(buttonParam)
local inputParam = {input_function = 'drawInput', label = drawNum, color = {0,0,0}, font_color = stringColorToRGB('White'), function_owner = self,
position = {0,0.1,-0.5}, rotation = {0,0,0}, width = 300, height = 200, font_size = 150, alignment = 3, validation = 2}
self.createInput(inputParam)
local buttonParam = {click_function = 'decDraw', label = "-", color = stringColorToRGB('White'), function_owner = self,
position = {-0.25,0.1,0}, rotation = {0,0,0}, width = 250, height = 100, font_size = 150}
self.createButton(buttonParam)
local buttonParam = {click_function = 'incDraw', label = "+", color = stringColorToRGB('White'), function_owner = self,
position = {0.25,0.1,0}, rotation = {0,0,0}, width = 250, height = 100, font_size = 150}
self.createButton(buttonParam)
createLabelButton()
createPlayerButtons()
createStartButton()
createReturnButton()
end
function drawInput()
local tab = self.getInputs()
if tab[1].value == '' then
drawNum = 1
else
drawNum = tonumber(tab[1].value)
end
return drawNum
end
function sdMenu()
self.clearButtons()
state = 2
createTargetButtons()
createLabelButton()
createPlayerButtons()
createStartButton()
createReturnButton()
end
function spyMenu()
self.clearButtons()
state = 3
createLabelButton()
createPlayerButtons()
createStartButton()
createReturnButton()