forked from sionar/Botc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NightHelper.ttslua
1485 lines (1367 loc) · 52.4 KB
/
NightHelper.ttslua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
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
--[[
Night Tool
Made by Sionar
--]]
------------------Constants
VERSION = '3.0.10'
COLORS = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink', 'Magenta', 'Lavender', 'Navy', 'Cyan', 'Mint', 'Lime', 'Peach', 'Coral', 'Maroon', 'Silver', 'Grey'}
COLORS_BBC = {White = '[FFFFFF]', Brown = '[703A16]', Red = '[DA1917]', Orange = '[F3631C]', Yellow = '[E6E42B]', Green = '[30B22A]', Teal = '[20B09A]', Blue = '[1E87FF]', Purple = '[9F1FEF]', Pink = '[F46FCD]', Magenta = '[FF007F]', Lavender = '[967BB6]', Navy = '[616BD4]', Cyan = '[49D5FD]', Mint = '[89C381]', Lime = '[B8F161]', Peach = '[F1D4A2]', Coral = '[E29A8A]', Maroon = '[800000]', Silver = '[BEBEBE]', Black = '[3F3F3F]', Grey = '[888888]', Prompt = '[93EB6A]'}
COLORS_RGB = {White = {1,1,1}, Brown = {113/255,59/255,23/255}, Red = {219/255,26/255,24/255}, Orange = {244/255,100/255,29/255}, Yellow = {231/255,229/255,44/255}, Green = {49/255,179/255,43/255}, Teal = {33/255,177/255,155/255}, Blue = {31/255,136/255,255/255}, Purple = {160/255,32/255,240/255}, Pink = {245/255,112/255,206/255}, Magenta = {255/255,0/255,127/255}, Lavender = {150/255,123/255,182/255}, Navy = {97/255,107/255,212/255}, Cyan = {73/255,213/255,253/255}, Mint = {137/255,195/255,129/255}, Lime = {184/255,241/255,97/255}, Peach = {241/255,212/255,162/255}, Coral = {226/255,154/255,138/255}, Maroon = {128/255,0,0}, Silver = {190/255,190/255,190/255}, Grey = {136/255, 136/255, 136/255}}
ROW_S = -7.3
ROW_W = 0.45
FONT_SIZE = 225
FONT_SIZE_LABEL = 360
BUTTON_SIZE = 270
BUTTON_Y = 0.1
BUTTON_COLOR = {0,0,0}
BUTTON_FONT_COLOR = {1,1,1}
COLUMN = {-6, -4, -3.35, -2.70, -2.05, -1.5, 4, 6.3}
ROW = {}
for i = 1,40 do
ROW[i] = ROW_S + i * ROW_W
end
LIVING_LAB_Z = -7.75
NIGHT_LAB_Z = -7.75
PREVIEW_LAB_Z = 3.15
PREVIEW_MSG_Z = 4.3
ADDCHAR_LAB_X = -4
ADDCHAR_LAB_Z = 3.15
ADD_BUT_X = -0.8
INPUTS_X = {-5.5, -2.3}
INPUTS_LAB_Z = 4.1
INPUT_BUT_Z = 5
BOTTOM_BUT_X = {-8, -6.5, -5, -3.5}
BOTTOM_BUT_Z = 8
#include GUIDs.ttslua
------------------Variables
objects = {}
living = {}
order = {}
orderRef = nil
minionColorsDemon = {}
minionColorsMinion = {}
demonColorsDemon = {}
demonColorsMinion = {}
unblind = {}
blindAuto = true
checkPrompts = true
message = ''
charAdd = ''
colorAdd = ''
currentMsg = ''
sendMsg = ''
evilMsgDemon = ''
evilMsgMinion = ''
p1, p2, p3, p4 = '', '', '', ''
dayNum = 0
dayLog = {{}}
nightLog = {{}}
currentChar = ''
demonBluffs = {nil, nil, nil}
------------------Load/save
function onLoad(saveString)
TABLE_OFFSET = Global.getVar('TABLE_OFFSET')
assignObjects()
moveBoard()
if not (saveString == '') then
local save = JSON.decode(saveString)
living = save['l']
order = save['o']
orderRef = save['r']
demonColors = save['d']
unblind = save['u']
checkPrompts = save['c']
blindAuto = save['b']
dayNum = save['day']
nightLog = save['nl']
dayLog = save['dl']
end
refreshUI()
self.setDescription('v ' .. VERSION .. '\nMade by Sionar')
end
function onSave()
local save = {}
save['l'] = living
save['o'] = order
save['r'] = orderRef
save['d'] = demonColors
save['u'] = unblind
save['c'] = checkPrompts
save['b'] = blindAuto
save['day'] = dayNum
save['nl'] = nightLog
save['dl'] = dayLog
local saveString = JSON.encode(save)
return saveString
end
------------------Functions
function assignObjects()
objects.scriptingZone = getObjectFromGUID(SCRIPTING_ZONE_GUID)
objects.shroudBag = getObjectFromGUID(SHROUD_BAG_GUID)
objects.clockControls = getObjectFromGUID(CLOCK_CONTROLS_GUID)
end
function moveBoard()
local modName = Global.getVar('MOD_NAME')
local TABLE_OFFSET, STORYTELLER_TABLE_DIST
if modName == 'Blood on the Clocktower' then
TABLE_OFFSET = Global.getVar('TABLE_OFFSET')
STORYTELLER_TABLE_DIST = Global.getVar('STORYTELLER_TABLE_DIST')
self.setPositionSmooth({0,1.2,TABLE_OFFSET + STORYTELLER_TABLE_DIST + 27})
self.setLock(true)
end
end
function importCall()
import(_, 'Black')
end
function import(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
local chars = Global.getTable('chars')
local numChars = 0
local lunaticColor = false
local tempDemonColor
local demonName
local found = false
for k,v in pairs(chars) do
numChars = numChars + 1
end
if numChars == 0 then
return
end
local entry = {}
living = {}
minionColorsDemon = {}
minionColorsMinion = {}
demonColorsDemon = {}
demonColorsMinion = {}
for k,v in pairs(chars) do
playerChar = v
entry = {color = k, char = playerChar, used = false, alive = true, sober = true, sane = true}
table.insert(living, entry)
if CHARACTERS[playerChar].Type == 'Minion' then
found = false
for k1,v1 in pairs(minionColorsMinion) do
if v1 == entry.color then
found = true
break
end
end
if not found then
table.insert(minionColorsDemon, entry.color)
table.insert(minionColorsMinion, entry.color)
end
elseif CHARACTERS[playerChar].Type == 'Demon' then
found = false
for k1,v1 in pairs(demonColorsDemon) do
if v1 == entry.color then
found = true
break
end
end
if not found then
table.insert(demonColorsDemon, entry.color)
table.insert(demonColorsMinion, entry.color)
demonName = entry.char
end
end
if playerChar == 'Magician' then
found = false
for k1,v1 in pairs(demonColorsMinion) do
if v1 == entry.color then
found = true
break
end
end
if not found then
table.insert(demonColorsMinion, entry.color)
end
found = false
for k1,v1 in pairs(minionColorsDemon) do
if v1 == entry.color then
found = true
break
end
end
if not found then
table.insert(minionColorsDemon, entry.color)
end
end
end
for k,v in pairs(living) do
if v.char == 'Lunatic' then
lunaticColor = v.color
tempDemonColor = demonColorsDemon[1]
demonColorsDemon[1] = lunaticColor
v.char = demonName
for k1,v1 in pairs(living) do
if v1.color == tempDemonColor then
v1.char = 'Lunatic'
break
end
end
break
end
end
generateEvilMsgs()
setNightOrder('first')
setMsg()
end
function generateEvilMsgs()
local minionStrMinion = 'Minions:'
for i = 1, #minionColorsMinion do
minionStrMinion = minionStrMinion .. ' ' .. COLORS_BBC[minionColorsMinion[i]] .. minionColorsMinion[i] .. '[-]'
end
local minionStrDemon = 'Minions:'
for i = 1, #minionColorsDemon do
minionStrDemon = minionStrDemon .. ' ' .. COLORS_BBC[minionColorsDemon[i]] .. minionColorsDemon[i] .. '[-]'
end
local demonStrMinion = 'Demons:'
for i = 1, #demonColorsMinion do
demonStrMinion = demonStrMinion .. ' ' .. COLORS_BBC[demonColorsMinion[i]] .. demonColorsMinion[i] .. '[-]'
end
local demonStrDemon = 'Demons:'
for i = 1, #demonColorsDemon do
demonStrDemon = demonStrDemon .. ' ' .. COLORS_BBC[demonColorsDemon[i]] .. demonColorsDemon[i] .. '[-]'
end
evilMsgDemon = demonStrDemon .. ', ' .. minionStrDemon
evilMsgMinion = demonStrMinion .. ', ' .. minionStrMinion
end
function setNightOrder(night)
order = {}
local players = Global.call('updatePlayers')
local mode = Global.getVar('mode')
local poppy = false
if blindAuto then
for k,v in pairs(unblind) do
if players[v] ~= nil then
players[v].blindfolded = true
end
end
unblind = {}
end
if night == 'first' then
for k,v in pairs(living) do
if v.char == 'Poppy Grower' and v.alive then
poppy = true
end
end
if poppy == false then
table.insert(order, {char = 'Evil Info', color = 'White'})
end
table.insert(order, {char = 'Demon Info', color = demonColorsDemon[1]})
orderRef = FIRST[mode]
else
orderRef = OTHER[mode]
end
for k1,v1 in pairs(orderRef) do
for k2,v2 in pairs(living) do
if v2.char == v1 and v2.char ~= 'Ravenkeeper' and v2.char ~= 'Sage' and v2.char ~= 'Barber' and v2.char ~= 'Choirboy' and v2.char ~= 'Cartographer'then
if v2.alive and (CHARACTERS[v2.char].Ability == false or (CHARACTERS[v2.char].Ability == true and v2.used == false)) then
if v2.char == 'Lunatic' and night == 'first' then
table.insert(order, 1, {char = 'Lunatic InfoA', color = v2.color})
table.insert(order, 2, {char = 'Lunatic InfoB', color = v2.color})
table.insert(order, 3, {char = 'Lunatic InfoC', color = demonColorsDemon[1]})
table.insert(order, v2)
elseif v2.char == 'Lunatic' and night == 'other' then
table.insert(order, v2)
table.insert(order, {char = 'Lunatic InfoD', color = demonColorsDemon[1]})
elseif v2.char == 'Godfather' and night == 'first' then
table.insert(order, {char = 'Godfather Info', color = v2.color})
elseif v2.char == 'Snitch' then
for k3, v3 in pairs(living) do
if CHARACTERS[v3.char].Type == 'Minion' then
table.insert(order, {char = 'Snitch', color = v3.color})
end
end
elseif v2.char == 'King' and night == 'first' then
table.insert(order, {char = 'King Info', color = demonColorsDemon[1]})
elseif v2.char == 'Rakshasa' and night == 'other' then
table.insert(order, v2)
table.insert(order, {char = 'Rakshasa Kill', color = v2.color})
elseif v2.char == 'Ysbaddaden' and night == 'other' then
table.insert(order, v2)
table.insert(order, {char = 'Ysbaddaden Kill', color = v2.color})
elseif v2.char == 'Jabberwocky' and night == 'other' then
table.insert(order, v2)
table.insert(order, {char = 'Jabberwocky Kill', color = v2.color})
elseif v2.char == 'Chieftain' and night == 'first' then
table.insert(order, {char = 'Chieftain Info', color = v2.color})
elseif v2.char == 'Trapper' and night == 'first' then
table.insert(order, {char = 'Trapper Info', color = v2.color})
elseif v2.char == 'Ambusher' and night == 'first' then
table.insert(order, {char = 'Ambusher Info', color = v2.color})
elseif v2.char == 'Bogman' and night == 'first' then
table.insert(order, {char = 'Bogman Info', color = v2.color})
elseif v2.char == 'Inquisitor' and night == 'other' then
table.insert(order, {char = 'Inquisitor Info', color = v2.color})
elseif CHARACTERS[v2.char].Response == true then
table.insert(order, v2)
table.insert(order, {char = v2.char .. '2', color = v2.color})
else
table.insert(order, v2)
end
end
end
end
end
for k,v in pairs(living) do
if not v.sane then
table.insert(order, {char = 'Madness', color = v.color})
end
end
table.insert(order, {char = 'Next Night', color = 'White'})
sortOrder()
currentChar = order[1].char
setMsg()
modifyPrompts(currentChar)
end
function sortOrder()
local sortedOrder = {}
for k,v in pairs(orderRef) do
for k1,v1 in pairs(order) do
if v == v1.char then
table.insert(sortedOrder, v1)
end
end
end
order = sortedOrder
currentChar = order[1].char
end
function setMsg()
if #order == 0 then
currentMsg = ''
sendMsg = ''
refreshUI()
return
end
local char = order[1].char
if currentChar ~= char then
currentChar = char
modifyPrompts(char)
end
if currentChar == 'Evil Info' then
currentMsg = evilMsgDemon
elseif currentChar == 'Demon Info' then
setDemonBluffs()
modifyPrompts('Demon Info')
return
elseif currentChar == 'Next Night' then
currentMsg = ''
else
currentMsg = CHARACTERS[currentChar].Prompt
end
sendMsg = currentMsg
refreshUI()
end
function setDemonBluffs()
local zoneObjs = objects.scriptingZone.getObjects()
local pos, gmNotes
local formattedBluffs = {'P1', 'P2', 'P3'}
local textColor
demonBluffs = {nil,nil,nil}
for k,v in pairs(zoneObjs) do
pos = v.getPosition()
gmNotes = v.getGMNotes()
if gmNotes == 'Character Token' and math.abs(pos[1] - 4) < 1 and math.abs(pos[3] - 129) < 1 then
demonBluffs[1] = v.getName()
elseif gmNotes == 'Character Token' and math.abs(pos[1] - 0) < 1 and math.abs(pos[3] - 129) < 1 then
demonBluffs[2] = v.getName()
elseif gmNotes == 'Character Token' and math.abs(pos[1] + 4) < 1 and math.abs(pos[3] - 129) < 1 then
demonBluffs[3] = v.getName()
end
end
for i,v in pairs(demonBluffs) do
if v ~= nil then
if CHARACTERS[v].Type == 'Townsfolk' then
textColor = COLORS_BBC['Blue']
elseif CHARACTERS[v].Type == 'Outsider' then
textColor = COLORS_BBC['Teal']
elseif CHARACTERS[v].Type == 'Minion' then
textColor = COLORS_BBC['Orange']
elseif CHARACTERS[v].Type == 'Demon' then
textColor = COLORS_BBC['Red']
elseif CHARACTERS[v].Type == 'Traveler' then
textColor = COLORS_BBC['Green']
end
formattedBluffs[i] = textColor .. v .. '[-]'
end
end
currentMsg = CHARACTERS['Demon Info'].Prompt
p1 = formattedBluffs[1]
p2 = formattedBluffs[2]
p3 = formattedBluffs[3]
editMsg()
end
function getKey(table, value)
for k,v in pairs(table) do
if value == v then
return k
end
end
return nil
end
function inTable(table, value)
for k,v in pairs(table) do
if v == value then
return true
end
end
return false
end
function used(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
local entry = living[i]
local char = living[i].char
local offset = 0
living[i].used = not living[i].used
if CHARACTERS[char].Ability == true and living[i].used == true then
for j = #order, 1, -1 do
if living[i].char == order[j].char then
table.remove(order, j)
end
end
if CHARACTERS[char].Response == true then
for k,v in pairs(order) do
if living[i].char .. '2' == v.char then
table.remove(order, k)
end
end
end
end
setMsg()
end
for k = 1,30 do
_G['used' .. k] = function(obj, col)
used(obj, col, k)
end
end
function alive(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
local entry = {color = living[i].color, char = living[i].char}
living[i].alive = not living[i].alive
if not living[i].alive and (entry.char == 'Ravenkeeper' or entry.char == 'Sage' or entry.char == 'Barber' or entry.char == 'King' or entry.char == 'Cartographer') then
if orderRef ~= nil then
orderIndex = getKey(orderRef, entry.char)
if orderIndex == nil then
refreshUI()
return
end
for i = 1, #order do
if orderIndex < getKey(orderRef, order[i].char) then
orderPos = i
break
end
end
if orderPos == nil then
orderPos = #order + 1
end
if entry.char == 'Barber' or entry.char == 'Cartographer' then
entry.color = demonColorsDemon[1]
elseif entry.char == 'King' then
entry.color = nil
entry.char = 'Choirboy'
for j, value in ipairs(living) do
if value.char == 'Choirboy' and value.alive then
entry.color = value.color
break
end
end
removeCharFromOrder(living[i].char, living[i].color)
orderPos = orderPos - 1
end
if entry.color ~= nil then
table.insert(order, orderPos, {color = entry.color, char = entry.char})
end
if entry.char == 'Ravenkeeper' then
table.insert(order, orderPos + 1, {color = entry.color, char = 'Ravenkeeper2'})
end
end
elseif not living[i].alive and living[i].char == 'Poppy Grower' then
table.insert(order, 1, {char = 'Evil Info', color = 'White'})
elseif not living[i].alive then
removeCharFromOrder(living[i].char, living[i].color)
elseif living[i].alive then
addCharToOrder(living[i].char, living[i].color)
end
placeShroud(i)
setMsg()
end
for k = 1,30 do
_G['alive' .. k] = function(obj, col)
alive(obj, col, k)
end
end
function placeShroud(i)
local started = Global.getVar('started')
if not started then
return
end
local tableSize = Global.getVar('tableSize')
local angle = Global.getTable('angle')
local color = living[i].color
local rad = tableSize * 0.4 + 6
local pos = radius(rad, angle[color], 1.25)
pos['z'] = pos['z'] + 129 + TABLE_OFFSET
local found = nil
local zoneObjs = objects.scriptingZone.getObjects()
local vPos
if objects.shroudBag == nil then
return
end
for k,v in pairs(zoneObjs) do
if v.getName() == 'Shroud' then
vPos = v.getPosition()
if math.abs(vPos['x'] - pos['x']) < 1 and math.abs(vPos['z'] - pos['z']) < 1 then
found = v
break
end
end
end
if living[i].alive then
if found then
objects.shroudBag.putObject(found)
end
else
if not found then
objects.shroudBag.takeObject({position = pos, rotation = {0,0,0}})
end
end
end
function radius(rad, angle, height)
return {x = rad*math.sin(angle*math.pi/180), y = height, z = rad*math.cos(angle*math.pi/180)}
end
function sober(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
living[i].sober = not living[i].sober
setMsg()
end
for k = 1,30 do
_G['sober' .. k] = function(obj, col)
sober(obj, col, k)
end
end
function sane(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
local entry = living[i]
local char = living[i].char
local found = false
living[i].sane = not living[i].sane
if living[i].sane then
for k,v in pairs(order) do
if v.char == 'Madness' and v.color == entry.color then
table.remove(order,k)
end
end
else
for k,v in pairs(order) do
if v.char == 'Madness' and v.color == entry.color then
found = true
break
end
end
if not found then
table.insert(order, {char = 'Madness', color = entry.color})
sortOrder()
end
end
currentChar = order[1].char
setMsg()
modifyPrompts(currentChar)
end
for k = 1,30 do
_G['sane' .. k] = function(obj, col)
sane(obj, col, k)
end
end
function remove(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
local entry = living[i]
local num = 0
for k,v in pairs(living) do
if v.color == entry.color then
num = num + 1
end
end
table.remove(living, i)
if num <= 1 then
local chars = Global.getTable('chars')
chars[entry.color] = nil
Global.setTable('chars', chars)
Global.call('removeCharText', entry.color)
end
for k,v in pairs(minionColorsMinion) do
if v == entry.color then
table.remove(minionColorsMinion,k)
end
end
for k,v in pairs(minionColorsDemon) do
if v == entry.color then
table.remove(minionColorsDemon,k)
end
end
for k,v in pairs(demonColorsMinion) do
if v == entry.color then
table.remove(demonColorsMinion,k)
end
end
for k,v in pairs(demonColorsDemon) do
if v == entry.color then
table.remove(demonColorsDemon,k)
end
end
generateEvilMsgs()
removeCharFromOrder(entry.char, entry.color)
setMsg()
end
for k = 1,30 do
_G['remove' .. k] = function(obj, col)
remove(obj, col, k)
end
end
function send(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
local steam_name = Player[playerColor].steam_name
local sendColor, msg
local players = Global.call('updatePlayers')
local allBlind = objects.clockControls.getVar('allBlind')
if objects.clockControls ~= nil then
objects.clockControls.call('hideGrimoire')
end
if order[1].char == 'Evil Info' then
for i = 1, #demonColorsDemon do
msg = COLORS_BBC['Black'] .. 'Black' .. ' [888888]-> ' .. COLORS_BBC[demonColorsDemon[i]] .. demonColorsDemon[i] .. '[-]: ' .. evilMsgDemon
table.insert(nightLog[#nightLog], {sender = 'Black', receiver = demonColorsDemon[i], message = evilMsgDemon})
if players[demonColorsDemon[i]] ~= nil then
players[demonColorsDemon[i]].print(msg)
end
printToColor(msg, 'Black', {1,1,1})
end
for i = 1, #minionColorsMinion do
msg = COLORS_BBC['Black'] .. 'Black' .. ' [888888]-> ' .. COLORS_BBC[minionColorsMinion[i]] .. minionColorsMinion[i] .. '[-]: ' .. evilMsgMinion
table.insert(nightLog[#nightLog], {sender = 'Black', receiver = minionColorsMinion[i], message = evilMsgMinion})
if players[minionColorsMinion[i]] ~= nil then
players[minionColorsMinion[i]].print(msg)
end
printToColor(msg, 'Black', {1,1,1})
end
elseif order[1].char == 'Demon Info' then
for i = 1, #demonColorsDemon do
msg = COLORS_BBC['Black'] .. 'Black' .. ' [888888]-> ' .. COLORS_BBC[demonColorsDemon[i]] .. demonColorsDemon[i] .. '[-]:[-] ' .. COLORS_BBC['Prompt'] .. sendMsg .. '[-]'
table.insert(nightLog[#nightLog], {sender = 'Black', receiver = demonColorsDemon[i], message = sendMsg})
if players[demonColorsDemon[i]] ~= nil then
players[demonColorsDemon[i]].print(msg)
end
printToColor(msg, 'Black', {1,1,1})
end
if blindAuto then
for k,v in pairs(unblind) do
if players[v] ~= nil then
players[v].blindfolded = true
end
end
unblind = {}
for i = 1, #demonColors do
table.insert(unblind, demonColorsDemon[i])
if players[demonColorsDemon[i]] ~= nil then
players[demonColorsDemon[i]].blindfolded = false
end
end
end
elseif order[1].char == 'Next Night' then
if blindAuto then
for k,v in pairs(unblind) do
if players[v] ~= nil then
players[v].blindfolded = true
end
end
unblind = {}
end
setNightOrder('other')
setMsg()
dayNum = dayNum + 1
local history = Global.getTable('history')
table.insert(history, '\n[808080]----------Day ' .. dayNum .. '----------[-]')
Global.setTable('history', history)
table.insert(dayLog, {})
table.insert(nightLog, {})
return
elseif order[1].char == 'Lil Monsta' then
for i = 1, #minionColors do
msg = COLORS_BBC['Black'] .. 'Black' .. ' [888888]-> ' .. COLORS_BBC[minionColorsMinion[i]] .. minionColorsMinion[i] .. '[-]:[-] ' .. COLORS_BBC['Prompt'] .. sendMsg .. '[-]'
table.insert(nightLog[#nightLog], {sender = 'Black', receiver = minionColorsMinion[i], message = sendMsg})
if players[minionColorsMinion[i]] ~= nil then
players[minionColorsMinion[i]].print(msg)
end
printToColor(msg, 'Black', {1,1,1})
end
if blindAuto then
for k,v in pairs(unblind) do
if players[v] ~= nil then
players[v].blindfolded = true
end
end
unblind = {}
for i = 1, #minionColorsMinion do
table.insert(unblind, minionColorsMinion[i])
if players[minionColorsMinion[i]] ~= nil then
players[minionColorsMinion[i]].blindfolded = false
end
end
end
else
if checkPrompts then
if string.match(sendMsg, 'P1') or string.match(sendMsg, 'P2') or string.match(sendMsg, 'P3') or string.match(sendMsg, 'P4') then
Player[playerColor].print('Error: Fill in the prompts before sending the message.', {1,0,0})
-- setMsg()
-- editMsg()
return
end
end
sendColor = order[1].color
msg = COLORS_BBC['Black'] .. 'Black [888888]-> ' .. COLORS_BBC[sendColor] .. sendColor .. '[-]:[-] ' .. COLORS_BBC['Prompt'] .. sendMsg .. '[-]'
if players[sendColor] ~= nil then
players[sendColor].print(msg)
end
printToColor(msg, 'Black', {1,1,1})
table.insert(nightLog[#nightLog], {sender = 'Black', receiver = sendColor, message = sendMsg})
if blindAuto and order[1].char ~= 'Lunatic InfoA' then
for k,v in pairs(unblind) do
if players[v] ~= nil then
players[v].blindfolded = true
end
end
unblind = {}
table.insert(unblind, order[1].color)
if players[unblind[1]] ~= nil then
players[unblind[1]].blindfolded = false
end
end
end
table.remove(order, 1)
p1, p2, p3, p4 = 'P1', 'P2', 'P3', 'P4'
setMsg()
end
function skip(clickedObject, playerColor, i)
if playerColor ~= 'Black' then
return
end
table.remove(order, i)
p1, p2, p3, p4 = 'P1', 'P2', 'P3', 'P4'
setMsg()
end
for k = 1,30 do
_G['skip' .. k] = function(obj, col)
skip(obj, col, k)
end
end
function nullFunc() end
function firstNight(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
setNightOrder('first')
end
function otherNight(clickedObject, playerColor)
if playerColor ~= 'Black' then
return
end
setNightOrder('other')
end
function charInput(obj, color, input, stillEditing)
if not stillEditing then
local found = false
local formattedInput = input
for k,v in pairs(CHARACTERS) do
if string.lower(k) == string.lower(formattedInput) and formattedInput ~= ''
and (v.Type == 'Townsfolk' or v.Type == 'Outsider' or v.Type == 'Minion' or v.Type == 'Demon' or v.Type == 'Traveler') then
charAdd = k
found = true
break
end
end
if found then
refreshUI()
return 1
end
for k,v in pairs(CHARACTERS) do
if string.match(string.lower(k), string.lower(formattedInput)) and formattedInput ~= ''
and (v.Type == 'Townsfolk' or v.Type == 'Outsider' or v.Type == 'Minion' or v.Type == 'Demon' or v.Type == 'Traveler') then
charAdd = k
break
end
end
refreshUI()
return 1
end
end
function colorDropSelect(player, value, id)
colorAdd = value
end
function modifyPrompts(character)
local uiTab = self.UI.getXmlTable()
local char_list
local mode = Global.getVar('mode')
local colors = Global.getTable('colors')
local customList = Global.getTable('customList')
if mode == 'TB' then
char_list = TB_LIST
elseif mode == 'BM' then
char_list = BM_LIST
elseif mode == 'SV' then
char_list = SV_LIST
elseif mode == 'CU' then
char_list = customList
end
local dropdown, id
for i = 1,4 do
promptKey = 'P' .. i
dropdown = uiTab[i+1].children[1]
dropdown.children = {}
if PROMPTS[character] and PROMPTS[character][promptKey] ~= nil then
uiTab[i+1].attributes.active = true
insertOption(dropdown.children, "Prompt ".. i)
if PROMPTS[character][promptKey].type == 'Demon Info' then
for k,char in pairs(char_list) do
if CHARACTERS[char].Type == 'Townsfolk' or CHARACTERS[char].Type == 'Outsider' then
if char == demonBluffs[i] then
insertOption(dropdown.children, char, true)
else
insertOption(dropdown.children, char, false)
end
end
end
elseif PROMPTS[character][promptKey].type == 'Character' then
if PROMPTS[character][promptKey].quality == 'All' then
for k,char in pairs(char_list) do
insertOption(dropdown.children, char)
end
elseif PROMPTS[character][promptKey].quality == 'Good' then
for k,char in pairs(char_list) do
if CHARACTERS[char].Type == 'Townsfolk' or CHARACTERS[char].Type == 'Outsider' then
insertOption(dropdown.children, char)
end
end
elseif PROMPTS[character][promptKey].quality == 'Evil' then
for k,char in pairs(char_list) do
if CHARACTERS[char].Type == 'Minion' or CHARACTERS[char].Type == 'Demon' then
insertOption(dropdown.children, char)
end
end
else
for k,char in pairs(char_list) do
if CHARACTERS[char].Type == PROMPTS[character][promptKey].quality then
insertOption(dropdown.children, char)
end
end
end
elseif PROMPTS[character][promptKey].type == 'Color' then
for k,color in pairs(colors) do
insertOption(dropdown.children, color)
end
elseif PROMPTS[character][promptKey].type == 'Number' then
for j = PROMPTS[character][promptKey].min, PROMPTS[character][promptKey].max do
insertOption(dropdown.children, j)
end
elseif PROMPTS[character][promptKey].type == 'State' then
if PROMPTS[character][promptKey].quality == 'Alignment' then
insertOption(dropdown.children, "Good")
insertOption(dropdown.children, "Evil")
elseif PROMPTS[character][promptKey].quality == 'Is' then
insertOption(dropdown.children, "is")
insertOption(dropdown.children, "is not")
elseif PROMPTS[character][promptKey].quality == 'Are' then
insertOption(dropdown.children, "are")
insertOption(dropdown.children, "are not")
elseif PROMPTS[character][promptKey].quality == 'Has' then
insertOption(dropdown.children, "has")
insertOption(dropdown.children, "has not")
elseif PROMPTS[character][promptKey].quality == 'Have' then
insertOption(dropdown.children, "have")
insertOption(dropdown.children, "do not have")
elseif PROMPTS[character][promptKey].quality == 'Do' then
insertOption(dropdown.children, "do")
insertOption(dropdown.children, "do not")
end
end
else
uiTab[i+1].attributes.active = false
end
end
self.UI.setXmlTable(uiTab)
end
function insertOption(tab, value, selected)
local attributes = nil
if selected then
attributes = {selected = true}
end
local option = {
tag = "Option",
value = value,
attributes = attributes,
children = nil
}
table.insert(tab, option)
end
function promptSelect(player, value, id)
local num = string.sub(id, -1, -1)
local str = value
local textColor
if string.match(str, "Prompt") then
str = "P" .. string.sub(str, -1, -1)
elseif PROMPTS[currentChar]['P'..num].type == 'Color' then
str = COLORS_BBC[value] .. value .. '[-]'
elseif PROMPTS[currentChar]['P'..num].type == 'Character' or PROMPTS[currentChar]['P'..num].type == 'Demon Info' then
if CHARACTERS[value].Type == 'Townsfolk' then
textColor = COLORS_BBC['Blue']