-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdivingoverlaysV3.4.2.lua
2578 lines (2420 loc) · 131 KB
/
divingoverlaysV3.4.2.lua
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
--[[
** __ ______ ____ ______ _ __ ___ _ __ ______ ______ __ ______ _ __
** / | / ___ / /__ \ /_ __/ | | / / / __ \ | | / / / _____/ / __ / / / / __ /| | / /
** / / | / /__/ / / _/ / / | | / / / / | | | | / / / /__ / /__/ / / / / /__/ / | |_/ /
** / /| | / __ | / /__ / / | |/ / | |_/ / | |/ / / /___ / __ | / /___ / __ / |_ _/
** /____/ /_/ |_| /_____/ /_/ |__/ |____/ |__/ /______| /_/ |_|/_____/ /_/ /_/ /_/ TM
**
**
** Open Broadcaster Software
**
** OBS > Tools > Scripts
**
** OBS Lua Script :- divingoverlaysVx.y.z.lua
** matching OBS Source JSON File :- divingoverlays-sourceVx.y.z.json
**
** Provides a number of OBS-Studio Text(GDI+) Sources which displays the event information from DiveRecorder (DR) onto the event video stream. Uses the UDP data provided by DR on the local network
** and after checking displays the new information. Has the capability to automatically hide the dive information banner and re-display it when DR data changes. Works for both Individual events
** and Synchro events and a vairable number of judges. Will work for simultaneous events but only display the data for one of the simultaneous events (Event A or B). Does not work for a skills
** circuit and should be disabled else random info show! Most UDP script components by OBS Forum's John Hartman, with thanks.
**
** V3.0.0a 2022-07-05 A developement branch from V2.1.2 to implement UDP communications. Don't use, unlikly to be working!!
** V3.0.0b 2022-10-25 Further deveopement on the use of UDP for communications. Mainly rationalisation of the code and removal of file monitoring code. Don't use, unlikly to be fully working!!
** V3.0.0c 2022-10-28 Working version using UDP communications from DR. Penalty description now included in awards overlay as approporate. Auto selection between Individual or Synchro events.
** V3.0.1 2022-11-02 Working version. However still issues with initilisation of the HotKeys. Best if user cycles each function key after the start of OBS. Test of using two UDP ports.
** V3.1.0a 2022-11-05 Using UDP to determine how many judges are being used (and displayed in Status). Synchro 5 judge and 7 judge option now included. Source JSON file updated for 5 and 7
** synchro judges.
** V3.1.0b 2022-11-12 A test version to investigate the anomilies when running a skills circuit.
** V3.1.0c 2022-11-22 Update to fix minor issues with layout and the non display of end of event status indicator. For Plaform events, board height added after dive description. Source JSON
** updated for new concept of Total and Marks Source rather then just one called Scores
** V3.1.0d 2022-12-14 Connecting to all four UDP ports but only processing messages from two and using messages from one (at this time)!
** V3.1.0e 2023-01-11 Windows path capture and use now correct. Only two UDP ports needed at present, 58091 and 58093. The other two not used.
** V3.1.0 2023-01-28 Version for National Cup testing. No further changes or updates anticipated.
** V3.1.1 2023-04-20 Minor bug fix for F5 hotkey, which did not do anything usefull anyway! Re-purpose F3 to be 'Re-display Overlay' hotkey.
** V3.1.2 2023-04-24 Clean-up. No functional changes.
** V3.1.3 2023-mm-nn Work in progress so use V3.1.2 for events. Preperatery changes to provide a dual display for simultaneous events. Should be no functional change from V3.1.2 though and may even work!
** 2023-05-08 No changes just a few code clean-ups to start with
** 2023-09-29 More code clean-ups. Only 2 UDP ports monitored.
** V3.2.1 2023-10-01 Added code for Ctrl+F12 (or Shft+F12) hotkey but does not do anything useful yet as can't get key modifier (Ctrl or Shft) to work.
** V3.2.2 2023-10-29 Re-factored for single_update and simultaneous_update screen update functions (functions names may change). Simultaneous or Single mode change uses 'S' as hotkey to move
** between modes, likly to change though!
** V3.3.0 2023-11-08 'single_update' re-factored to match 'simultaneous_update' format and also both simplified. Few wrinkles in the display formating but working for both single event and
** simultaneous event modes.
** V3.3.1 2023-11-10 Changed Hotkey assignment to make mode change the F12 key. Will need the new Source file to match, divingoverlays-obssourceV3.3.1.json
** V3.3.2 2023-11-23 Added capability to swap overlay positions when in Simultaneous mode using the F10 key. Added F8 and F6 in Simultaneous mode to clear Left and Right displays respectively.
** Fixed Penalty bug.
** V3.3.3 2024-04-07 Minor corrections. F6 labels for the different F12 modes now seperated and show correctly.
** V3.3.4 2024-06-15 Removed redundent F8 display background in Simultaneous mode.
** V3.3.5 2024-07-02 F6 background now correct in Simultaneous mode even if Event B is in Individual mode when switched. Event Complete indicator not shown in Simultaneous mode.
** V3.4.0 2024-07-04 Code simplified to monitor only one UDP port. Noticed at last event that rendering errors occure at 60fps even with i9 + nVid4070 graphics laptop doing the processing! Other ports
** code not removed just commented out.
** V3.4.1 2024-11-09 Minor code clean-up. Updated some comments to make them easer to read and understand.
** V3.4.2 2024-11-20 Fix bug where the 7.5m board height is not added to the dive description in the Overlay.
**
** Packet ID (58091 REFEREE) split_string2[1] Packet ID (58091 AVIDEO)
** a or b event split_string2[2] a or b event
** Sending Computer ID split_string2[3] Sending Computer ID
** Event mode split_string2[4] Event mode
** New Event split_string2[5] Event Status
** Round split_string2[6] eom (^, 94 dec, 5E hex)
** Attempt by diver split_string2[7]
** Start No split_string2[8]
** D1 Full Name + Team split_string2[9]
** D1 Family Name split_string2[10]
** D2 Full Name + Team split_string2[11]
** D2 Family Name split_string2[12]
** Dive No split_string2[13]
** Position split_string2[14]
** DD split_string2[15]
** Board split_string2[16]
** J1: E1: E1: E1: E1: split_string2[17]
** J2: E2: E2: E2: E2: split_string2[18]
** J3: E3: E3: E3: split_string2[19]
** J4: E4: E4: E4: split_string2[20]
** J5: E5: split_string2[21]
** J6: E6: split_string2[22]
** J7: S1: S1: S1: S1: split_string2[23]
** J8: S2: S2: S2: S2: split_string2[24]
** J9: S3: S3: S3: S3: split_string2[25]
** J10: S4: S4: split_string2[26]
** J11: S5: S5: split_string2[27]
** Judge Total split_string2[28]
** Points split_string2[29]
** Total split_string2[30]
** Scoreboard Display Mode split_string2[31]
** Rank split_string2[32]
** Prediction split_string2[33]
** Likly rank split_string2[34]
** Background colour split_string2[35]
** AText colour split_string2[36]
** BText colour split_string2[37]
** Caption colour split_string2[38]
** Message 1 - Line 1 of 8 split_string2[39]
** Message 2 split_string2[40]
** Message 3 split_string2[41]
** Message 4 ( ½ a store) split_string2[42]
** Message 5 split_string2[43]
** Message 6 split_string2[44]
** Message 7 split_string2[45]
** Message 8 - Line 8 of 8 split_string2[46]
** Synchro event? split_string2[47]
** Show running total score split_string2[48]
** Show prediction split_string2[49]
** Number of Judges split_string2[50]
** Penalty code split_string2[51]
** Station No for cct events split_string2[52]
** Number of stations split_string2[53]
** D1 First Name split_string2[54]
** D1 Team Name split_string2[55]
** D1 Team Code split_string2[56]
** D2 First Name split_string2[57]
** D2 Team Name split_string2[58]
** D2 Team Code split_string2[59]
** Long event name split_string2[60]
** Dive Description split_string2[61]
** Meet Title split_string2[62]
** No of Rounds in event split_string2[63]
** No of Divers in event split_string2[64]
** Short dive description split_string2[65]
** Conversion factor split_string2[66]
** Short event name split_string2[67]
** Team A2 split_string2[68]
** Team code A2 split_string2[69]
** Team B2 split_string2[70]
** Team code B2 split_string2[71]
** Seconds per dive split_string2[72]
** Do Not Rank flag split_string2[73]
** Team event split_string2[74]
** eom (^, 94 dec , 5E hex) split_string2[75]
]]
local obs = obslua
local socket = require("ljsocket")
local our_server1 = nil
--[[local our_server2 = nil
local our_server3 = nil
local our_server4 = nil ]]
local portClient = 58091 -- the main port for DR broadcast data
--[[local portServer = 58092 -- port for DR Server locate and identification
local portWebUp = 58093 -- to send to LiveResults via DR2Web
local portAwards = 58094 -- server port for awards and perhaps ranking ]]
Address1 = socket.find_first_address("*", portClient)
--[[Address2 = socket.find_first_address("*", portServer)
Address3 = socket.find_first_address("*", portWebUp)
Address4 = socket.find_first_address("*", portAwards) ]]
local currentDataClient -- to check if latest received data has changed
local interval = 1000 -- (ms), time between update file checks -- Again now not needed for UDP communications
local dinterval -- the time to display the TV overlay after update
local debug -- turn on or off debug information display in the Log
local synchro = false -- default is Individual event
local simultaneousEvents = false -- default is Single event
local event = "Event 1" -- default location for Event source overlay
local eventB = false -- switch for using Event B data
local activeId = 0 -- active file check id's, incremented for each programme parameter change or script initiated re-start
local current = {} -- current data file values to compare with next file update
local resultK = {} -- empty array where we will store data from the first UDP port data stream
local resultL = {} -- empty array where we will store data from the second UDP port data stream
local resultM = {} -- empty array where we will store data from the third UDP port data stream
local resultN = {} -- empty array where we will store data from the fouth UDP port data stream
local togglevar1, togglevar2, togglevar3 = false, false, false -- to aid Hotkey Toggle functions
local disableUpdate, eventComplete = false, false -- as it says!
local tvBanner_removed = false -- is or is not the banner being displayed?
local fileContentsChanged = true -- has the data file changed since the last update flag? -- And again not needed for UDP comms
local hideDisable = false -- default is to hide overlays after timeout
-- Hotkey definitions and default settings, (not realy OBS Set-up functions). Don't use F11 as it is a predefined 'Full Screen' trigger
htk_1 = obs.OBS_INVALID_HOTKEY_ID -- seems to work just as well without these declarations but all on-line info says to do this so here we go!
htk_2 = obs.OBS_INVALID_HOTKEY_ID
htk_3 = obs.OBS_INVALID_HOTKEY_ID
htk_4 = obs.OBS_INVALID_HOTKEY_ID
htk_5 = obs.OBS_INVALID_HOTKEY_ID
htk_6 = obs.OBS_INVALID_HOTKEY_ID
htk_7 = obs.OBS_INVALID_HOTKEY_ID
htk_8 = obs.OBS_INVALID_HOTKEY_ID
htk_9 = obs.OBS_INVALID_HOTKEY_ID
htk_10 = obs.OBS_INVALID_HOTKEY_ID
htk_12 = obs.OBS_INVALID_HOTKEY_ID
positionText = { -- not used in V3.4.n yet
A = ", straight",
B = ", piked",
C = ", tucked",
D = ", free position"
}
penaltyText = { -- not used in V3.4.n yet
" ",
" Failed Dive ",
" Restarted \n -2 points ",
"Flight or Danger\n Max 2 points ",
" Arm position \n Max 4½ points "
}
local plugin_info = {
name = "Diving Overlays",
version = "3.4.2",
url = "https://github.com/andy5211d/DR2TVOverlay",
description = "Video stream overlay of Diverecorder data for springboard and highboard diving competitions",
author = "andy5211d"
}
local plugin_def = {
id = "DR2TVOverlay",
type = obs.OBS_SOURCE_TYPE_INPUT,
output_flags = bit.bor(obs.OBS_SOURCE_CUSTOM_DRAW),
}
function getPath(str) -- Sorts out the Windows path seperator character for file access. Now only used for flag file access
return str:match("(.*[/\\])")
end -- getPath()
-- Single Mode. Called when a valid UDP message is detected. Process DR data in the message then display and for a user determined period if Overlay hide option not disabled.
local function single_update(v)
obs.script_log(obs.LOG_INFO, string.format("start single_update(), Message Headder: " .. v[1]) .. " received") -- show in log what is happening (message header)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Event Complete? %s", eventComplete))
obs.script_log(obs.LOG_INFO, string.format("tvBanner Removed? %s", tvBanner_removed))
obs.script_log(obs.LOG_INFO, string.format("File contents changed? %s", fileContentsChanged))
obs.script_log(obs.LOG_INFO, string.format("hideDisable: %s", hideDisable))
obs.script_log(obs.LOG_INFO, string.format("synchro: %s", synchro))
obs.script_log(obs.LOG_INFO, string.format("eventB: %s", eventB))
end
if eventComplete and tvBanner_removed and not fileContentsChanged then -- try to stop the banner re-displaying when showing rankings. Hmm, is this really doing what it says?
return
end
if v[1] ~= ("REFEREE") then return end
split_string2 = v -- now we are processing a UDP message
-- update the OBS Status display (old F9) with current settings.
if synchro then -- message processing for status update
local source = obs.obs_get_source_by_name("Event_Type") -- Event type: Synchro
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", "Synchro Event")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("F9_Function_Background_True") -- disable background
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("F9_Function_Background_False") -- enable background
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
else
local source = obs.obs_get_source_by_name("Event_Type") -- Event type: Individual
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", "Individual Event")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("F9_Function_Background_False") -- disable background
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("F9_Function_Background_True") -- enable background
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
end -- end status single_update
local source = obs.obs_get_source_by_name("NoJudges") -- Display number of judges in corner of F9 Status box
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", ("No Judges: " .. split_string2[50]))
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
if split_string2[32] == ("") then -- sort out a Nul in array as lua strings can't contain a Nul
split_string2[32] = (" ")
obs.script_log(obs.LOG_INFO, string.format("Nul detected in Rank field (so first round)"))
end
eventComplete = false
tvBanner_removed = false -- as we are about to display dive data or awards!
-- produce the event information display
local event_info = (" " .. split_string2[60] .. " \n Diver " .. split_string2[8] .. "/" .. split_string2[64] .. " Round " .. split_string2[6] .. "/" .. split_string2[63] .. " ")
local source = obs.obs_get_source_by_name("EventData") -- Display event data
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", event_info)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name(event) -- enable text Source (Event group)
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source at start of single_update(): " .. event))
end
end
-- end of Status display single_update
-- first generate empty text display lines
lineOne = (" ") -- set overlay display text line 1 to 50 spaces
lineTwo = (" ") -- set overlay display text line 2 to 50 spaces
-- generate country flag or club logo file info from udp data.
local flag_file = getPath(flagLoc) .. split_string2[56].. ".png"
if debug then
obs.script_log(obs.LOG_INFO, string.format("Flag File = " .. flag_file))
end
local ft, err = io.open(flag_file, "rb") -- try to open the flag file and if it exists then use it, else use Default.png
if not ft then
if debug then
obs.script_log(obs.LOG_INFO, string.format("Flag file not found, using default flag file"))
end
local index = flag_file:match'^.*()/' -- find last occurance of the path seperator
if index == "" then index = 0 end -- fix error generated by networked DR instance sending scoreboard clear function
flag_file = string_insert(flag_file, "Default.png", index) -- inset default logo if required flag file code not found (string_insert starts at 0. This will produce a sting.insert length error but acceptable as not for a formated text display)
else
ft:close()
end
local source = obs.obs_get_source_by_name("Flag") -- Divers country flag or club logo insert into source.
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "file", flag_file)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
-- end of flag display process
-- now generate lineOne of the overlay text, the Divers, preceded by rank
display1a = (" " .. split_string2[32] .. " ") -- rank
lineOne = string_insert(lineOne, display1a, 0)
display1b = (" ")
if synchro then
displayName = (split_string2[54] .. ' ' .. split_string2[10] .. ' + ' .. split_string2[57] .. ' ' .. split_string2[12] .. ' ' .. split_string2[56] .. '/' .. split_string2[59]) -- display names + clubs
lineOne = string_insert(lineOne, displayName, 5) -- where is the Total text generated??
else
displayName = (split_string2[9]) -- display name and club
lineOne = string_insert(lineOne, displayName, 5)
scores1 = split_string2[29] -- points *** why here? part of lineTwo end of J awards.
end
if split_string2[17] ~= (" ") then -- if awards in J1 field then display them
-- generate the Penalty text, if there is one ***** make this a table look-up *****
if split_string2[51] == "0" then penalty = (" ")
elseif split_string2[51] == "1" then penalty = (" Failed Dive ")
elseif split_string2[51] == "2" then penalty = (" Restarted \n -2 points ")
elseif split_string2[51] == "3" then penalty = ("Flight or Danger\n Max 2 points ")
elseif split_string2[51] == "4" then penalty = (" Arm position \n Max 4½ points ")
end
sourcelineTwo = (" ") -- empty sourcelineTwo field to ensure dive description removed
if synchro then -- display synchro judge awards
if split_string2[50] == "11" then -- 11 synchro judges (Judge role labels are in different positions for other number of judges!)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Synchro 11 Judge display selected"))
end
local source = obs.obs_get_source_by_name("SynchroJLabels5")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
-- place judge awards into their respective text Sources
local source = obs.obs_get_source_by_name("J1") -- Judge E1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[17])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J2") -- Judge E2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[18])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J3") -- Judge E3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[19])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J4") -- Judge E4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[20])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J5") -- Judge E5 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[21])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J6") -- Judge E6 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[22])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J7") -- Judge S1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[23])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J8") -- Judge S2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[24])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J9") -- Judge S3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[25])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J10") -- Judge S4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[26])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J11") -- Judge S5 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[27])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
elseif split_string2[50] == "9" then -- 9 synchro judges (Judge role labels are in different positions for other no of judges!)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Synchro 9 Judge display selected"))
end
local source = obs.obs_get_source_by_name("SynchroJLabels5")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
-- place awards into their respective text Sources
local source = obs.obs_get_source_by_name("J1") -- Judge E1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[17])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J2") -- Judge E2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[18])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J3") -- Judge E3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[19])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J4") -- Judge E4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[20])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J5") -- Judge S1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[23])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J6") -- Judge S2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[24])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J7") -- Judge S3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[25])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J8") -- Judge S4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[26])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J9") -- Judge S5 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[27])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J10") -- Judge 10 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J11") -- Judge 11 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
elseif split_string2[50] == "7" then -- 7 synchro judges (Judge role labels are in different positions for other no of judges!)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Synchro 7 Judge display selected"))
end
local source = obs.obs_get_source_by_name("SynchroJLabels5")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
-- place awards into their respective text Sources
local source = obs.obs_get_source_by_name("J1") -- Judge E1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[17])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J2") -- Judge E2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[18])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J3") -- Judge E3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[19])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J4") -- Judge E4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[20])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J5") -- Judge S1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[23])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J6") -- Judge S2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[24])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J7") -- Judge S3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[25])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J8") -- Judge 8 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J9") -- Judge 9 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J10") -- Judge 10 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J11") -- Judge 11 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
elseif split_string2[50] == "5" then -- 5 synchro judges (Judge role labels are in different positions for other no of judges!)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Synchro 5 Judge display selected"))
end
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels5")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
-- place awards into their respective text Sources
local source = obs.obs_get_source_by_name("J1") -- Judge E1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[17])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J2") -- Judge E2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[18])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J3") -- Judge S1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[23])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J4") -- Judge S2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[24])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J5") -- Judge S3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[25])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J6") -- Judge 6 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J7") -- Judge 7 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J8") -- Judge 8 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J9") -- Judge 9 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J10") -- Judge 10 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J11") -- Judge 11 blank
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", " ")
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
else
error("Invalid number of synchro judges")
end
else -- display individual judge awards
local source = obs.obs_get_source_by_name("SynchroJLabels11") -- disable synchro11 judge role labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels9") -- disable synchro9 judges role labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels7") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels5") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("JudgeAwards") -- Enable awards Text Source group (else 11 individual text boxes sources to enable!)
if source ~= nil then
obs.obs_source_set_enabled(source, true)
end
obs.obs_source_release(source)
-- place judge awards into their respective text Sources (yes could be a nested loop but this was a simple copy paste!!)
local source = obs.obs_get_source_by_name("J1") -- Judge 1 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[17])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J2") -- Judge 2 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[18])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J3") -- Judge 3 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[19])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J4") -- Judge 4 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[20])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J5") -- Judge 5 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[21])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J6") -- Judge 6 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[22])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J7") -- Judge 7 awards insert
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[23])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J8") -- Judge 8 awards insert. Should be a space!
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[24])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J9") -- Judge 9 awards insert. Should be a space!
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[25])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J10") -- Judge 10 awards insert. Should be a space!
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[26])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("J11") -- Judge 11 awards insert. Should be a space!
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", split_string2[27])
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
local source = obs.obs_get_source_by_name("JudgeAwards") -- Enable awards Text Source group
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
-- Event Complete?
if split_string2[8] == split_string2[64] and split_string2[6] == split_string2[63] then
eventComplete = true
local source = obs.obs_get_source_by_name("Event_Complete") -- show blue status rectangle in 'Status' source dock
if source ~= nil then
obs.obs_source_set_enabled(source, true)
obs.obs_source_release(source)
end
if debug then
obs.script_log(obs.LOG_INFO, string.format("Synchro Event Complete!"))
end
else
eventComplete = false
local source = obs.obs_get_source_by_name("Event_Complete") -- disable blue status rectangle in 'Status' source dock
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
end
else -- no awards so show dive info
penalty = (" ") -- ensure last penalty removed
local source = obs.obs_get_source_by_name("JudgeAwards") -- Disable awards Text Source group
if source ~= nil then
obs.obs_source_set_enabled(source, false)
obs.obs_source_release(source)
end
local source = obs.obs_get_source_by_name("SynchroJLabels5") -- Disable synchro judge labels
if source ~= nil then