forked from LostSavage/SecretHitlerCE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ttslua
More file actions
3118 lines (2881 loc) · 102 KB
/
main.ttslua
File metadata and controls
3118 lines (2881 loc) · 102 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
--Static
--Boards and Buttons
settingsPannel_guid = '39d283'
fasPannel_guid = 'c09dbd'
drawPileBoard_guid = 'a5b10f'
discardPileBoard_guid = '3e225f'
radio_string = '●'
check_string = '✓'
--Decks/Cards
hitler_deck_guid = '5997ea'
fascist_deck_guids = {'5f2055','fb58cf', '4a3cf4'}
fascist_deck_extra_guid = 'd60f75'
liberal_deck_guids = {'b156f7', 'd1735a', 'c8ab2a', 'b2873d', '313939', '40d8f5'}
liberal_deck_extra_guid = '304115'
extraRole_card_guids = {'675a6f', '16e480', '0a5960', '02b664', '328440', '05df40', '98f4dd', '7b4b46', 'ccb7ed', 'c2309a'}
fakeMembership_card_guid = '55d1c3'
fascistMembership_card_guid = 'e4d489'
liberalMembership_card_guid = 'a73564'
GREY_POLICY_RIGHT = -9
GREY_EXPANSION_RIGHT = 9
--Placards and Tracker
PRESIDENT_GUID = "4d3d8f"
PREV_PRESIDENT_GUID = "780217"
PREV_PRESIDENT_POS = {x = -16.5, y = 1.06, z = -17}
PREV_PRESIDENT_ROT = {x = 0, y = 270, z = 0}
CHANCELOR_GUID = "7dba7e"
PREV_CHANCELOR_GUID = "448483"
PREV_CHANCELOR_POS = {x = 16.5, y = 1.06, z = -17}
PREV_CHANCELOR_ROT = {x = 0, y = 90, z = 0}
ELECTION_TRACKER_GUID = "dd57c4"
--Scripting Zones
DRAW_ZONE_GUID = '6463d3'
DISCARD_ZONE_GUID = 'b9bd6e'
ABILITIESPILE_ZONE_GUID = 'eea120'
EFFECTSPILE_ZONE_GUID = '374a16'
fascist_zone_guids = {'1f0149', '390247', '6c3840', '13e460', '441bbf', '6a906e', '488053'}
liberal_zone_guids = {'12b8ce', '3cabfa', '6f02b7', '939e6d', '3f80ba', 'a6b76f'}
topdeck_zone_guid = 'c0b577'
policySafety_zone_guids = {White = 'e99663', Brown = '13b335', Red = 'd7774a', Orange = 'f601b1', Yellow = '620e09', Green = 'b7c2d8', Teal = '162d55', Blue = '0aa61b', Purple = 'fdc17a', Pink = 'c4d8e8'}
--Other
HIDDEN_ZONE_GUIDS = {White = "f13d0b", Brown = "90049b", Red = "134297", Orange = "344002", Yellow = "9b5558", Green = "7a8301", Teal = "568a75", Blue = "dbd95e", Purple = "cc1b94", Pink = "d954ee"}
trusted_players = {'76561197992512677'}
boardGreen_rgb = {14/255, 45/255, 18/255}
boardBrown_rgb = {53/255, 27/255, 17/255}
lastVote_guids = {'88c953', 'ba4919', 'b7dcde', '4598da'}
-- @{100, 100, 100+} hidden zones
-- @{-100, 100, -100} is used to delete/spawn objects
--Variable
customOnly = nil
bannerZoneGuid = nil
topdeck = false
lastDrawCt = nil
lastPlayerCt = nil
hold = false
votes = {}
disableVote = false
votePassed = false
blockDraw = false
--Wait timers
voteWaitId = nil
policyWaitId = nil
boardCardWaitId = nil
--Saved data
activePowerColor = nil
bannerGuids = {}
bulletInfo = {
type = 'Custom_Model',
mesh = 'http://cloud-3.steamusercontent.com/ugc/487893695357489958/2749FC201350D558AC9DF373861E4323C8B354BB/',
diffuse = '',
assetbundle = nil,
assetbundle_secondary = nil,
convex = true,
image = nil,
material = 2,
specular_color = {1, 1, 0.5882353},
specular_intensity = 1.7,
specular_sharpness = 8.0,
fresnel_strength = 0,
use_grid = false,
colorTint = {0, 0, 0.0382530019},
scale = {0.75, 0.75, 0.75},
action = 'Shoots',
status = 'Dead',
shooterColor = nil
}
fascists = {}
forcePres = nil
greyAvatarGuids = {}
greyPlayerSteamIds = {}
greyPlayerHandGuids = {}
hitler = {}
imprisonInfo = {
type = 'Custom_Model',
mesh = 'http://cloud-3.steamusercontent.com/ugc/993492686551248783/B83B87475B885192F8F820E381F1D70A2E3F1919/',
diffuse = 'http://cloud-3.steamusercontent.com/ugc/993492686551247160/63699220060380A49761207FF81A12E1AB00A597/',
assetbundle = nil,
assetbundle_secondary = nil,
convex = true,
image = nil,
material = 2,
specular_color = {0.737, 0.737, 0.737},
specular_intensity = 0.9,
specular_sharpness = 7.0,
fresnel_strength = 0,
use_grid = false,
colorTint = {1, 1, 1},
scale = {4, 4, 4},
action = 'Imprisons',
status = 'Imprisoned',
shooterColor = nil
}
inspected = {}
jaCardGuids = {}
lastFascistPlayed = 0
lastLiberalPlayed = 0
lastChan = nil
lastPres = nil
lastVote = ''
mainNotes = ''
neinCardGuids = {}
notate = {
line = nil,
action = ''
}
noteTakerNotes = {}
noteTakerCurrLine = 0
options = {
autoNotate = false,
dealPartyCards = false,
dealRoleCards = false,
expansionAmount = 2,
expansionOptionEnabled = 0, -- [1 SwapGov, 2 Reverse, 4 SwapPower, 8 SetupPowerAbilities]
expansionOptionStatus = 0, -- [1 SwapGov, 2 Reverse]
expansionOptionText = {'Pres -> Chan', 'Chan -> Pres', 'Clockwise', 'Counterclockwise'},
fascistCards = 11,
greyCards = 0,
gameType = 0, -- [0 Original, 2 Custom]
liberalCards = 6,
noteType = 1, -- [1 Dark wood, 2 Light wood, 3 Red wood, 4 Black plastic, 5 Board image, 6 Swiss cheese, 7 Private only, 8 Cooperative]
policySafety = true,
scriptedVoting = true,
shufflePlayers = false,
shuffleHost = true,
voteHistory = false,
zoneType = 4 -- [1 None, 2 Small, 3 Gap (version 1), 4 Gap (version 2), 5 Large, 6 11-12 Players]
}
players = {}
playerRoleCardGuids = {}
playerStatusButtonGuids = {}
playerStatus = { --[1 Board, 2 Not Hitler, 3 Vote Only, 4 Silenced, 5 Dead, 6 Dead not Hitler]
White = 1,
Brown = 1,
Red = 1,
Orange = 1,
Yellow = 1,
Green = 1,
Teal = 1,
Blue = 1,
Purple = 1,
Pink = 1,
Tan = 1,
Maroon = 1
}
roles = {}
started = nil
text = {
hitler = 'Hitler',
liberal = 'Liberal',
liberalAbbr = 'Liberal',
liberalArticle = 'a',
liberalLetter = 'L',
fascist = 'Fascist',
fascistAbbr = 'Fascist',
fascistArticle = 'a',
fascistLetter = 'F',
grey = 'Grey',
greyAbbr = 'Grey',
greyArticle = 'a',
greyLetter = 'G',
policy = 'policy'
}
voteNotes = ''
voteNotebook = ''
-- Called when a game finishes loading
function onLoad(saveString)
if not (saveString == '') then
local save = JSON.decode(saveString)
activePowerColor = save['a']
bannerGuids = save['b']
bulletInfo = save['bi']
fascists = save['f']
forcePres = save['fp']
greyAvatarGuids = save['gag']
greyPlayerSteamIds = save['gp']
greyPlayerHandGuids = save['gphg']
hitler = save['h']
imprisonInfo = save['ii']
inspected = save['in']
jaCardGuids = save['ja']
lastFascistPlayed = save['lfp']
lastLiberalPlayed = save['llp']
lastChan = save['lc']
lastPres = save['lp']
lastVote = save['lv']
mainNotes = save['mn']
neinCardGuids = save['nein']
notate = save['note']
noteTakerNotes = save['ntn']
noteTakerCurrLine = save['ntcl']
options = save['o']
players = save['p']
playerRoleCardGuids = save['prcg']
playerStatus = save['ps']
playerStatusButtonGuids = save['psbg']
roles = save['r']
started = save['s']
text = save['t']
voteNotes = save['vn']
voteNotebook = save['vnb']
end
alwaysInit()
if not started then
mainNotes = '[FFFF00]Secret Hitler: Consolidator Edition\n' ..
'Version ' .. UPDATE_VERSION .. ' (' .. string.len(Global.getLuaScript()) .. ')\n' ..
'\n[-]Based on the board game:\n\n[FF0000]Secret Hitler[-]\ndesigned by\n[0080F8]Max Temkin[-],\n[0080F8]Mike Boxleiter[-],\n[0080F8]Tommy Maranges[-]\nand Illustrated by\n[0080F8]Mackenzie Schubert.[-]\n\n' ..
'Check the notebook for additional\ninformation and subscribe on the\nworkshop to make sure you have the\nlatest version.\n\n' ..
'Only the president can draw cards.\n\nTo topdeck a card move the election tracker\nto the \34REVEAL & PASS TOP POLICY\34 circle.\n\n'
setNotes(mainNotes)
local status, err = pcall(init)
if not status then
printToAll('ERROR LOADING: ' .. err, {1,0,0})
end
settingsPannelMakeButtons()
refreshBoardCards()
end
if not noteTakerCurrLine or noteTakerCurrLine == 0 then
noteTakerNotes = {}
noteTakerCurrLine = 0
addNewLine()
end
end
function onSave()
local save = {}
save['a'] = activePowerColor
save['b'] = bannerGuids
save['bi'] = bulletInfo
save['f'] = fascists
save['fp'] = forcePres
save['gag'] = greyAvatarGuids
save['gp'] = greyPlayerSteamIds
save['gphg'] = greyPlayerHandGuids
save['h'] = hitler
save['ii'] = imprisonInfo
save['in'] = inspected
save['ja'] = jaCardGuids
save['lfp'] = lastFascistPlayed
save['llp'] = lastLiberalPlayed
save['lc'] = lastChan
save['lp'] = lastPres
save['lv'] = lastVote
save['mn'] = mainNotes
save['nein'] = neinCardGuids
save['note'] = notate
save['ntn'] = noteTakerNotes
save['ntcl'] = noteTakerCurrLine
save['o'] = options
save['p'] = players
save['prcg'] = playerRoleCardGuids
save['ps'] = playerStatus
save['psbg'] = playerStatusButtonGuids
save['r'] = roles
save['s'] = started
save['t'] = text
save['vn'] = voteNotes
save['vnb'] = voteNotebook
local saveString = JSON.encode(save)
return saveString
end
function refreshHiddenZones()
for _, player in pairs(MAIN_PLAYABLE_COLORS) do
if options.zoneType == 1 then
--Hide the hidden zone so we can still use it later
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setScale({0.01, 0.01, 0.01})
local colorToNumber = {White = 1, Brown = 2, Red = 3, Orange = 4, Yellow = 5, Green = 6, Teal = 7, Blue = 8, Purple = 9, Pink = 10}
tmpObj.setPosition({100, 100, 100 + colorToNumber[player] * 2})
elseif options.zoneType == 2 then
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setScale({15.3268776, 5.1, 6.35014629})
forceObjectToPlayer(tmpObj, player, {forward = 0, right = 0, up = 0, forceHeight = 3.51}, NO_ROT)
elseif options.zoneType == 3 then
local pos = {White = {29.65, 3.51, -32.75}, Brown = {0, 3.51, -32.75}, Red = {-29.65, 3.51, -32.75}, Orange = {-50.2, 3.51, -19.25}, Yellow = {-50.2, 3.51, 19.25}, Green = {-29.65, 3.51, 32.75}, Teal = {0, 3.51, 32.75}, Blue = {29.65, 3.51, 32.75}, Purple = {50.2, 3.51, 19.25}, Pink = {50.2, 3.51, -19.25}}
local scale = {White = {28.4, 5.1, 10.1}, Brown = {28.4, 5.1, 10.1}, Red = {28.4, 5.1, 10.1}, Orange = {9.55, 5.1, 37.25}, Yellow = {9.55, 5.1, 37.25}, Green = {28.4, 5.1, 10.1}, Teal = {28.4, 5.1, 10.1}, Blue = {28.4, 5.1, 10.1}, Purple = {9.55, 5.1, 37.25}, Pink = {9.55, 5.1, 37.25}}
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setPosition(pos[player])
tmpObj.setScale(scale[player])
tmpObj.setRotation(NO_ROT)
elseif options.zoneType == 4 then
local pos = {White = {29.65, 3.51, -31.9}, Brown = {0, 3.51, -31.9}, Red = {-29.65, 3.51, -31.9}, Orange = {-50.2, 3.51, -19.25}, Yellow = {-50.2, 3.51, 19.25}, Green = {-29.65, 3.51, 31.9}, Teal = {0, 3.51, 31.9}, Blue = {29.65, 3.51, 31.9}, Purple = {50.2, 3.51, 19.25}, Pink = {50.2, 3.51, -19.25}}
local scale = {White = {28.4, 5.1, 11.8}, Brown = {28.4, 5.1, 11.8}, Red = {28.4, 5.1, 11.8}, Orange = {9.55, 5.1, 37.25}, Yellow = {9.55, 5.1, 37.25}, Green = {28.4, 5.1, 11.8}, Teal = {28.4, 5.1, 11.8}, Blue = {28.4, 5.1, 11.8}, Purple = {9.55, 5.1, 37.25}, Pink = {9.55, 5.1, 37.25}}
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setPosition(pos[player])
tmpObj.setScale(scale[player])
tmpObj.setRotation(NO_ROT)
elseif options.zoneType == 5 then
local pos = {White = {29.3, 3.51, -31.9}, Brown = {0, 3.51, -31.9}, Red = {-29.3, 3.51, -31.9}, Orange = {-49.4, 3.51, -19}, Yellow = {-49.4, 3.51, 19}, Green = {-29.3, 3.51, 31.9}, Teal = {0, 3.51, 31.9}, Blue = {29.3, 3.51, 31.9}, Purple = {49.4, 3.51, 19}, Pink = {49.4, 3.51, -19}}
local scale = {White = {29.3, 5.1, 11.8}, Brown = {29.3, 5.1, 11.8}, Red = {29.3, 5.1, 11.8}, Orange = {10.8, 5.1, 38.0}, Yellow = {10.8, 5.1, 38.0}, Green = {29.3, 5.1, 11.8}, Teal = {29.3, 5.1, 11.8}, Blue = {29.3, 5.1, 11.8}, Purple = {10.8, 5.1, 38.0}, Pink = {10.8, 5.1, 38.0}}
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setPosition(pos[player])
tmpObj.setScale(scale[player])
tmpObj.setRotation(NO_ROT)
elseif options.zoneType == 6 then
local pos = {White = {-29.3, 3.51, -49.4}, Brown = {-49.4, 3.51, -29.3}, Red = {-49.4, 3.51, 0}, Orange = {-49.4, 3.51, 29.3}, Yellow = {-29.3, 3.51, 49.4}, Green = {0, 3.51, 49.4}, Teal = {29.3, 3.51, 49.4}, Blue = {49.4, 3.51, 29.3}, Purple = {49.4, 3.51, 0}, Pink = {49.4, 3.51, -29.3}}
local scale = {White = {28.4, 5.1, 10.8}, Brown = {10.8, 5.1, 28.4}, Red = {10.8, 5.1, 28.4}, Orange = {10.8, 5.1, 28.4}, Yellow = {28.4, 5.1, 10.8}, Green = {28.4, 5.1, 10.8}, Teal = {28.4, 5.1, 10.8}, Blue = {10.8, 5.1, 28.4}, Purple = {10.8, 5.1, 28.4}, Pink = {10.8, 5.1, 28.4}}
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
tmpObj.setPosition(pos[player])
tmpObj.setScale(scale[player])
tmpObj.setRotation(NO_ROT)
local handPos = {White = {-29.3, 4.46, -51.66}, Brown = {-51.66, 4.46, -29.3}, Red = {-51.66, 4.46, 0}, Orange = {-51.66, 4.46, 29.3}, Yellow = {-29.3, 4.46, 51.66}, Green = {0, 4.46, 51.66}, Teal = {29.3, 4.46, 51.66}, Blue = {51.66, 4.46, 29.3}, Purple = {51.66, 4.46, 0}, Pink = {51.66, 4.46, -29.3}}
local handRot = {White = {0, 0, 0}, Brown = {0, 90, 0}, Red = {0, 90, 0}, Orange = {0, 90, 0}, Yellow = {0, 180, 0}, Green = {0, 180, 0}, Teal = {0, 180, 0}, Blue = {0, 270, 0}, Purple = {0, 270, 0}, Pink = {0, 270, 0}}
local handParams = {
scale = {11.66, 5.4, 4.87}
}
handParams.position = handPos[player]
handParams.rotation = handRot[player]
Player[player].setHandTransform(handParams)
tmpObj = getObjectFromGUID(policySafety_zone_guids[player])
forceObjectToPlayer(tmpObj, player, {forward = 0, right = 0, up = 0, forceHeight = 3.51}, NO_ROT)
end
end
if options.zoneType == 6 then
broadcastToAll('Alpha release ... still work in progress.', {1,1,1})
local params = {type = 'Custom_Model', sound = false}
local tableExt = {}
local custom = {
mesh = 'http://cloud-3.steamusercontent.com/ugc/933812827275737908/4A39E65F99D7809D6055BED44C2B2AF420776850/',
diffuse = 'http://cloud-3.steamusercontent.com/ugc/933812827275738471/DBC87C418A1CBD45F4EB56EB0F63B65E7F042F1F/',
type = 4,
material = 1,
specular_color = {223/255, 207/255, 190/255},
specular_intensity = 0.05,
specular_sharpness = 6.3
}
for i = 1, 2 do
tableExt[i] = spawnObject(params)
tableExt[i].setCustomObject(custom)
tableExt[i].setLock(true)
tableExt[i].setRotation({0, 270, 0})
tableExt[i].setScale({0.74, 1, 1})
tableExt[i].setLuaScript(
'function onLoad()\r\n' ..
' self.interactable = false\r\n' ..
'end\r\n')
end
tableExt[1].setPosition({0, 0.1, -46.2})
tableExt[2].setPosition({0, 0.1, 46.2})
params = {
type = 'Custom_Assetbundle',
scale = {14.2, 2.55, 5.4},
callback = 'greyPlayerHandCallback',
sound = false
}
custom = {
assetbundle = 'http://cloud-3.steamusercontent.com/ugc/933813375181578705/3961A9B3B73895140CA5055A8745BEE4A3E39299/'
}
local playerHands = {}
for i, color in ipairs(GREY_PLAYABLE_COLORS) do
playerHands[i] = spawnObject(params)
playerHands[i].setCustomObject(custom)
playerHands[i].setColorTint(GREY_PLAYABLE_COLORS_RGB[color])
playerHands[i].setDescription(color .. ' Hand')
playerHands[i].setLock(true)
end
playerHands[1].setPosition({29.3, 3.5, -49.4}) -- Tan
playerHands[2].setPosition({0, 3.5, -49.4}) -- Maroon
refreshUI()
end
end
function onObjectEnterScriptingZone(zone, enterObject)
if enterObject then
if zone.guid == topdeck_zone_guid and enterObject.guid == ELECTION_TRACKER_GUID then
editButtonByLabel(drawPileBoard_guid, 'Draw 3', 'Topdeck', 'topdeckCard')
end
end
end
function onObjectLeaveScriptingZone(zone, leaveObject)
if leaveObject then
if zone.guid == topdeck_zone_guid and leaveObject.guid == ELECTION_TRACKER_GUID then
editButtonByLabel(drawPileBoard_guid, 'Topdeck', 'Draw 3', 'drawThree')
elseif options.policySafety then
if inTable(policySafety_zone_guids, zone.guid) and leaveObject.tag == 'Card' and
(leaveObject.getDescription() == FASCISTPOLICY_STRING or
leaveObject.getDescription() == LIBERALPOLICY_STRING) then
if not leaveObject.is_face_down and leaveObject.held_by_color then
broadcastToColor('Keep your policy cards face down\nwhen removing them from your hand!', leaveObject.held_by_color, {1, 0, 0})
leaveObject.deal(1, leaveObject.held_by_color)
end
end
end
end
end
function alwaysInit()
local tmpObj
-- Initialize the pseudo random number generator
math.randomseed(os.time())
refreshUI()
refreshStatusButtons()
refreshExpansionButtons()
local drawPileBoard = getObjectFromGUID(drawPileBoard_guid)
if drawPileBoard then
local button = {
click_function = 'drawThree',
label = 'Draw 3',
function_owner = Global,
position = {0, 0.14, 3.7},
rotation = {0, 0, 0},
width = 2700,
height = 1300,
font_size = 650
}
drawPileBoard.createButton(button)
end
for _, cardGUID in ipairs(extraRole_card_guids) do
local card = getObjectFromGUID(cardGUID)
if card then card.interactable = false end
end
tmpObj = getObjectFromGUID(fakeMembership_card_guid)
if tmpObj then tmpObj.interactable = false end
tmpObj = getObjectFromGUID(fascistMembership_card_guid)
if tmpObj then tmpObj.interactable = false end
tmpObj = getObjectFromGUID(liberalMembership_card_guid)
if tmpObj then tmpObj.interactable = false end
end
function refreshStatusButtons()
local tmpObj
local buttonGUID
for _, buttonGUID in ipairs(playerStatusButtonGuids) do
tmpObj = getObjectFromGUID(buttonGUID)
if tmpObj then
tmpObj.clearButtons()
local ownerColor = tmpObj.getName()
local button = {
function_owner = self,
position = {0, 0.2, 0},
rotation = {0, 180, 0},
width = 2900,
height = 1500,
font_size = 600,
click_function = 'changePlayerStatus'
}
if _G.playerStatus[ownerColor] == 1 then
if options.zoneType == 6 then
local greenColors = {'Brown', 'Red', 'Blue', 'Purple'}
if inTable(greenColors, ownerColor) then
button.color = boardGreen_rgb
else
button.color = boardBrown_rgb
end
else
button.color = boardGreen_rgb
end
button.label = ''
elseif _G.playerStatus[ownerColor] == 2 then
button.color = stringColorToRGB('Green')
button.label = 'Not ' .. text.hitler
elseif _G.playerStatus[ownerColor] == 3 then
button.color = stringColorToRGB('Yellow')
button.label = 'Vote Only'
elseif _G.playerStatus[ownerColor] == 4 then
button.color = stringColorToRGB('Blue')
button.label = 'Silenced'
elseif _G.playerStatus[ownerColor] == 5 then
button.color = stringColorToRGB('Red')
button.label = bulletInfo.status
elseif _G.playerStatus[ownerColor] == 6 then
button.color = stringColorToRGB('Red')
button.label = bulletInfo.status .. '\nNot ' .. text.hitler
else
button.color = stringColorToRGB('Red')
button.label = imprisonInfo.status
button.font_size = 550
end
tmpObj.createButton(button)
end
end
end
function refreshExpansionButtons()
local fasBoard = getObjectFromGUID(fasPannel_guid)
if fasBoard then
fasBoard.clearButtons()
local button = {
click_function = 'expansionOptionStatusSwapGov',
function_owner = self,
position = {12, 0.2, 6},
rotation = {0, 0, 0},
width = 2600,
height = 800,
font_size = 360
}
if bit32.band(options.expansionOptionStatus, 1) == 1 then
button.font_color = {0, 0, 0}
button.color = stringColorToRGB('Orange')
button.label = options.expansionOptionText[2]
else
button.font_color = stringColorToRGB('White')
button.color = boardGreen_rgb
button.label = options.expansionOptionText[1]
end
if bit32.band(options.expansionOptionEnabled, 1) == 1 then
fasBoard.createButton(button)
end
button.click_function = 'expansionOptionStatusReverse'
button.position = {-12, 0.2, 6}
button.width = 2800
if bit32.band(options.expansionOptionStatus, 2) == 2 then
button.font_color = {0, 0, 0}
button.color = stringColorToRGB('Orange')
button.label = options.expansionOptionText[4]
else
button.font_color = stringColorToRGB('White')
button.color = boardGreen_rgb
button.label = options.expansionOptionText[3]
end
if bit32.band(options.expansionOptionEnabled, 2) == 2 then
fasBoard.createButton(button)
end
end
end
function init()
local tmpObj
tmpObj = getObjectFromGUID(hitler_deck_guid)
if tmpObj == nil then error('Hitler Deck') end
tmpObj.interactable = false
tmpObj.setLock(true)
for i = 1, #fascist_deck_guids do
tmpObj = getObjectFromGUID(fascist_deck_guids[i])
if tmpObj == nil then error('Fascist Deck ' .. fascist_deck_guids[i]) end
tmpObj.interactable = false
tmpObj.setLock(true)
end
for i = 1, #liberal_deck_guids do
tmpObj = getObjectFromGUID(liberal_deck_guids[i])
if tmpObj == nil then error('Liberal Deck ' .. liberal_deck_guids[i]) end
tmpObj.interactable = false
tmpObj.setLock(true)
end
tmpObj = getObjectFromGUID(fascist_deck_extra_guid)
tmpObj.interactable = false
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(liberal_deck_extra_guid)
tmpObj.interactable = false
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(PRESIDENT_GUID)
if tmpObj == nil then error('President') end
tmpObj.interactable = false
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(CHANCELOR_GUID)
if tmpObj == nil then error('Chancellor') end
tmpObj.interactable = false
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(PREV_PRESIDENT_GUID)
if tmpObj == nil then error('Prev President') end
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(PREV_CHANCELOR_GUID)
if tmpObj == nil then error('Prev Chancellor') end
tmpObj.setLock(true)
tmpObj = getObjectFromGUID(ELECTION_TRACKER_GUID)
if tmpObj == nil then error('Election Tracker') end
tmpObj.setLock(true)
for i, player in ipairs(MAIN_PLAYABLE_COLORS) do
tmpObj = getObjectFromGUID(HIDDEN_ZONE_GUIDS[player])
if tmpObj == nil then error(player .. ' Hidden Zone') end
end
--Expansion
tmpObj = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
if tmpObj then tmpObj.interactable = false end
tmpObj = getDeckFromZoneByGUID(EFFECTSPILE_ZONE_GUID)
if tmpObj then tmpObj.interactable = false end
if options.gameType ~= 2 then
--delete board cards
testActionUsedPolicyZones(
function(p) return isBoardCard(p) or isPolicyNotUsedCard(p) end,
function(p) p.destruct() end,
nil)
end
end
function onChat(messageIn, player)
local message = string.gsub(messageIn, '%s+', ' ')
local messageTable = string.tokenize(message, ' ')
messageTable[1] = string.lower(messageTable[1])
if messageTable[1] == 'r' then
if started then
player:print(tellRole(player.color))
else
player:print('[FF0000]ERROR: Game not started.[-]')
end
return false
elseif messageTable[1] == 'l' then
player:print(lastVote)
return false
elseif messageTable[1] == 'h' then
if options.voteHistory then
player:print(string.gsub(voteNotebook, '\n$', ''))
else
player:print('[FF0000]ERROR: Full vote history is not enabled.[-]')
end
return false
elseif messageTable[1] == 'n' then
player:print(string.gsub(noteTakerNotesString(100, false, true), '\n$', ''))
return false
elseif messageTable[1] == 'o' then
player:print(string.gsub(tableToString(options), '\n$', ''))
return false
elseif messageTable[1] == 'v' then
player:print(versionInfo())
return false
elseif messageTable[1] == 'c' and (player.admin or inTable(trusted_players, player.steam_id)) then
if messageTable[2] then
messageTable[2] = string.titlecase(messageTable[2])
if inTable(MAIN_PLAYABLE_COLORS, messageTable[2]) or messageTable[2] == 'Black' or messageTable[2] == 'Grey' then
if messageTable[3] then
local playerFound = getPlayerByNameSteamID(messageTable[3], Player.getPlayers())
if playerFound then
playerFound:changeColor(messageTable[2])
else
player:print('ERROR: ' .. messageTable[3] .. ' not found.', {1, 0, 0})
end
else
player:changeColor(messageTable[2])
end
else
player:print('ERROR: Unknown color ' .. messageTable[2] .. '.', {1, 0, 0})
end
else
player:print('ERROR: No color given.', {1, 0, 0})
end
return false
elseif messageTable[1] == 'promote' and (player.admin or inTable(trusted_players, player.steam_id)) then
if messageTable[2] then
local playerFound = getPlayerByNameSteamID(messageTable[2], Player.getPlayers())
if playerFound then
playerFound.promote()
else
player:print(messageTable[2] .. ' not found.', {1, 0, 0})
end
else
player.promote()
end
return false
elseif messageTable[1] == 'kick' and (player.admin or inTable(trusted_players, player.steam_id)) then
if messageTable[2] then
local playerFound = getPlayerByNameSteamID(messageTable[2], Player.getPlayers())
if playerFound then
playerFound.kick()
else
player:print(messageTable[2] .. ' not found.', {1, 0, 0})
end
end
return false
elseif messageTable[1] == 'list' and (player.admin or inTable(trusted_players, player.steam_id)) then
for _, p in pairs(Player.getPlayers()) do
player:print(p.steam_name .. ' ' .. p.steam_id)
end
return false
elseif messageTable[1] == 'help' then
player:print(chatHelp(player.admin))
return false
end
for _, color in pairs(GREY_PLAYABLE_COLORS) do
if greyPlayerSteamIds[color] == player.steam_id then
printToAll("[" .. stringColorToHex(color) .. "]" .. player.steam_name .. ":[-] " .. messageIn)
return false
end
end
end
function chatHelp(admin)
local msg = 'chat commands:\n' ..
' r - All the role information you can know\n' ..
' l - Shows the last vote\n' ..
' h - Vote history\n' ..
' n - All of the notes\n' ..
' o - current options\n' ..
' v - Version info\n' ..
' help - This message'
if admin then
msg = msg .. '\nadmin chat commands:\n' ..
' c color [name* or steam id] - sets player to color\n' ..
' promote [name* or steam id] - promotes/demotes player\n' ..
' kick name* or steam id - kicks the player\n' ..
' list - lists steam ids\n' ..
' * partial name allowed but must be distinct'
end
return msg
end
function settingsPannelMakeButtons()
local settingsPannel = getObjectFromGUID(settingsPannel_guid)
if settingsPannel then
settingsPannel.clearButtons()
local buttonParam = {
font_color = {0, 0, 0},
rotation = {0, 0, 0},
width = 0,
height = 0,
font_size = 480,
function_owner = self,
click_function = 'nullFunction'
}
local startX = -6.1
local offsetZ = 1.32
local startZ = -22.9
buttonParam.label = '[u]Game Type[/u]'
buttonParam.position = {0, 0.2, startZ - 1.4}
settingsPannel.createButton(buttonParam)
makeSquareButtonLabel(settingsPannel, options.gameType == 0, radio_string, '', 'Original', 'gameTypeZero', {startX, 0.2, startZ}, 2.45, not customOnly)
makeSquareButtonLabel(settingsPannel, options.gameType == 2, radio_string, '', 'Custom', 'gameTypeTwo', {startX, 0.2, startZ + offsetZ * 1}, 2.3, true)
makeDecIncButtonsLabel(settingsPannel, options.liberalCards, '-', '+', 'Liberal Cards', 'decLiberalCards', 'incLiberalCards', {startX + 1.3, 0.2, startZ + offsetZ * 2}, 6.1, false, options.gameType == 2)
makeDecIncButtonsLabel(settingsPannel, options.fascistCards, '-', '+', 'Fascist Cards', 'decFascistCards', 'incFascistCards', {startX + 1.3, 0.2, startZ + offsetZ * 3}, 6.1, false, options.gameType == 2)
makeDecIncButtonsLabel(settingsPannel, options.greyCards, '-', '+', 'Grey Cards', 'decGreyCards', 'incGreyCards', {startX + 1.3, 0.2, startZ + offsetZ * 4}, 5.65, false, options.gameType == 2)
startZ = -14.5
buttonParam.label = '[u]Note Taker[/u]'
buttonParam.position = {0, 0.2, startZ - 1.4}
settingsPannel.createButton(buttonParam)
local labels = {'Dark wood', 'Light wood (tintable)', 'Red wood (tintable)', 'Black plastic', 'Board image', 'Swiss cheese', 'Private only', 'Cooperative'}
local offsets = {4.4, 6.6, 6.3, 4.7, 4.7, 4.7, 4.6, 4.6}
makeDecIncButtonsLabel(settingsPannel, options.noteType, '-', '+', labels, 'decNoteType', 'incNoteType', {startX, 0.2, startZ}, offsets, false, true)
startZ = -11.6
buttonParam.label = '[u]Hidden Zones[/u]'
buttonParam.position = {0, 0.2, startZ - 1.4}
settingsPannel.createButton(buttonParam)
labels = {'None', 'Small', 'Gap (version 1)', 'Gap (version 2)', 'Large', '11-12 Players'}
offsets = {3.2, 3.3, 5.3, 5.35, 3.3, 4.8}
makeDecIncButtonsLabel(settingsPannel, options.zoneType, '-', '+', labels, 'decZoneType', 'incZoneType', {startX, 0.2, startZ}, offsets, false, options.zoneType ~= 6)
startZ = -8.5
buttonParam.label = '[u]Other Options[/u]'
buttonParam.position = {0, 0.2, startZ - 1.4}
settingsPannel.createButton(buttonParam)
makeSquareButtonLabel(settingsPannel, options.dealRoleCards, check_string, '', 'Deal role', 'roleCardFlip', {startX, 0.2, startZ}, 2.7, true)
makeSquareButtonLabel(settingsPannel, options.dealPartyCards, check_string, '', 'Deal party membership', 'partyCardFlip', {startX, 0.2, startZ + offsetZ}, 5.8, true)
makeSquareButtonLabel(settingsPannel, options.scriptedVoting, check_string, '', 'Scripted voting', 'scriptedVotingFlip', {startX, 0.2, startZ + offsetZ * 2}, 4, true)
makeSquareButtonLabel(settingsPannel, options.autoNotate, check_string, '', 'Auto notate', 'autoNotateFlip', {startX, 0.2, startZ + offsetZ * 3}, 3.4, true)
makeSquareButtonLabel(settingsPannel, options.policySafety, check_string, '', 'Policy safety', 'policySafetyFlip', {startX, 0.2, startZ + offsetZ * 4}, 3.5, true)
makeSquareButtonLabel(settingsPannel, options.voteHistory, check_string, '', 'Vote history', 'voteHistoryFlip', {startX, 0.2, startZ + offsetZ * 5}, 3.4, true)
makeSquareButtonLabel(settingsPannel, options.shufflePlayers, check_string, '', 'Shuffle players', 'shufflePlayersFlip', {startX, 0.2, startZ + offsetZ * 6}, 4, true)
makeSquareButtonLabel(settingsPannel, options.shuffleHost, check_string, '', 'Shuffle host', 'shuffleHostFlip', {startX + 1.3, 0.2, startZ + offsetZ * 7}, 3.3, options.shufflePlayers)
--Expansion
local abilitiesDeck = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
if abilitiesDeck then
startZ = 3.7
buttonParam.label = '[u]Fan Expansion[/u]'
buttonParam.position = {0, 0.2, startZ - 1.4}
settingsPannel.createButton(buttonParam)
makeDecIncButtonsLabel(settingsPannel, options.expansionAmount, '-', '+', 'Cards', 'decExpansionAmount', 'incExpansionAmount', {startX, 0.2, startZ}, 4.7, false, true)
makeSquareButtonLabel(settingsPannel, bit32.band(options.expansionOptionEnabled, 1) == 1, check_string, '', 'Swap government', 'expansionOptionEnabledSwapGov', {startX, 0.2, startZ + offsetZ}, 4.7, true)
makeSquareButtonLabel(settingsPannel, bit32.band(options.expansionOptionEnabled, 4) == 4, check_string, '', 'Swap power', 'expansionOptionEnabledSwapPower', {startX + 1.3, 0.2, startZ + offsetZ * 2}, 3.4, bit32.band(options.expansionOptionEnabled, 1) == 1)
makeSquareButtonLabel(settingsPannel, bit32.band(options.expansionOptionEnabled, 2) == 2, check_string, '', 'Reverse', 'expansionOptionEnabledReverse', {startX, 0.2, startZ + offsetZ * 3}, 2.4, true)
makeSquareButtonLabel(settingsPannel, bit32.band(options.expansionOptionEnabled, 8) == 8, check_string, '', 'Setup power abilities', 'expansionOptionEnabledSetupPowerAbilities', {startX, 0.2, startZ + offsetZ * 4}, 5.3, true)
end
buttonParam = {
click_function = 'setupStart',
label = 'Start',
function_owner = self,
position = {0, 0.2, 23.5},
rotation = {0, 0, 0},
width = 3300,
height = 1700,
font_size = 750
}
settingsPannel.createButton(buttonParam)
else
printToAll('ERROR: Settings pannel not found.', {1,0,0})
end
end
function makeSquareButtonLabel(objectIn, valueIn, trueButtonTextIn, falseButtonTextIn, labelTextIn, clickFunctionIn, buttonPositionIn, textOffsetIn, enabledIn)
local buttonParam = {
rotation = {0, 0, 0},
width = 600,
height = 600,
font_size = 480,
function_owner = self,
click_function = clickFunctionIn,
position = buttonPositionIn
}
local textParam = {
label = labelTextIn,
font_color = {0, 0, 0},
rotation = {0, 0, 0},
width = 0,
height = 0,
font_size = 480,
function_owner = self,
click_function = 'nullFunction',
position = {buttonPositionIn[1] + textOffsetIn, buttonPositionIn[2], buttonPositionIn[3]}
}
if valueIn then
buttonParam.label = trueButtonTextIn
else
buttonParam.label = falseButtonTextIn
end
if not enabledIn then
buttonParam.click_function = 'nullFunction'
buttonParam.color = stringColorToRGB('Grey')
buttonParam.font_color = {0.3, 0.3, 0.3}
textParam.font_color = {0.3, 0.3, 0.3}
end
objectIn.createButton(buttonParam)
objectIn.createButton(textParam)
end
function makeDecIncButtonsLabel(objectIn, valueIn, decButtonTextIn, incButtonTextIn, labelTextIn, decFunctionIn, incFunctionIn, positionIn, textOffsetIn, showValueIn, enabledIn)
local buttonParam = {
font_color = {0, 0, 0},
rotation = {0, 0, 0},
width = 0,
height = 0,
font_size = 480,
function_owner = self,
click_function = 'nullFunction'
}
local valueOffset
if type(labelTextIn) == 'table' then
valueOffset = 0
buttonParam.label = labelTextIn[valueIn]
buttonParam.position = {positionIn[1] + textOffsetIn[valueIn], positionIn[2], positionIn[3]}
else
valueOffset = 1.3
buttonParam.label = labelTextIn
buttonParam.position = {positionIn[1] + textOffsetIn, positionIn[2], positionIn[3]}
end
if not enabledIn then
buttonParam.font_color = {0.3, 0.3, 0.3}
end
objectIn.createButton(buttonParam)
if not enabledIn then
buttonParam.color = stringColorToRGB('Grey')
end
buttonParam.label = decButtonTextIn
buttonParam.position = positionIn
buttonParam.width = 600
buttonParam.height = 600
if enabledIn then
buttonParam.click_function = decFunctionIn
end
objectIn.createButton(buttonParam)
buttonParam.label = incButtonTextIn
buttonParam.position = {positionIn[1] + 1.3 + valueOffset, positionIn[2], positionIn[3]}
if enabledIn then
buttonParam.click_function = incFunctionIn
end
objectIn.createButton(buttonParam)
if valueOffset > 0 then
buttonParam.label = valueIn
if enabledIn then
buttonParam.click_function = incFunctionIn
end
buttonParam.position = {positionIn[1] + valueOffset, positionIn[2], positionIn[3]}
objectIn.createButton(buttonParam)
end
end
function gameTypeZero(clickedObject, playerColor)
if Player[playerColor].admin then
options.gameType = 0
options.fascistCards = 11
options.liberalCards = 6
options.greyCards = 0
refreshBoardCards()
settingsPannelMakeButtons()
end
end
function gameTypeTwo(clickedObject, playerColor)
if Player[playerColor].admin then
options.gameType = 2
refreshBoardCards()
settingsPannelMakeButtons()
end
end
function decNoteType(clickedObject, playerColor)
if Player[playerColor].admin then
if options.noteType > 1 then
options.noteType = options.noteType - 1
end
settingsPannelMakeButtons()
end
end
function incNoteType(clickedObject, playerColor)
if Player[playerColor].admin then
if options.noteType < 8 then
options.noteType = options.noteType + 1
end
settingsPannelMakeButtons()
end
end
function decZoneType(clickedObject, playerColor)
if Player[playerColor].admin then
if options.zoneType > 1 then
options.zoneType = options.zoneType - 1
end
refreshHiddenZones()
settingsPannelMakeButtons()
end
end
function incZoneType(clickedObject, playerColor)
if Player[playerColor].admin then
if options.zoneType < 6 then
options.zoneType = options.zoneType + 1
end
refreshHiddenZones()
settingsPannelMakeButtons()
end
end
function roleCardFlip(clickedObject, playerColor)
if Player[playerColor].admin then
options.dealRoleCards = not options.dealRoleCards
settingsPannelMakeButtons()
end
end
function partyCardFlip(clickedObject, playerColor)
if Player[playerColor].admin then
options.dealPartyCards = not options.dealPartyCards
settingsPannelMakeButtons()
end
end
function scriptedVotingFlip(clickedObject, playerColor)
if Player[playerColor].admin then
options.scriptedVoting = not options.scriptedVoting
settingsPannelMakeButtons()
end
end
function autoNotateFlip(clickedObject, playerColor)
if Player[playerColor].admin then
options.autoNotate = not options.autoNotate
settingsPannelMakeButtons()