-
Notifications
You must be signed in to change notification settings - Fork 0
/
divingoverlaysV3.1.2.lua
2173 lines (2069 loc) · 108 KB
/
divingoverlaysV3.1.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 simultanious events but only display the data for one of the simultanious events (Event A or B). Does not work for a skills
** circuit and should be disabled else random info show! Initial 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! Re-purpose F3 to be 'Re-display Overlay' hotkey.
** V3.1.2 2023-04-24 Clean-up. No functional changes.
**
**
** 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 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 paramater 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 togglevar1, togglevar3 = false, false -- to aid Hotkey Toggle functions
local disableUpdate = false -- as it says!
local eventComplete = 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
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 go for it!
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
local plugin_info = {
name = "Diving Overlays",
version = "3.1.1",
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 file path seperator charactor
return str:match("(.*[/\\])")
end
-- 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 update(v)
obs.script_log(obs.LOG_INFO, string.format("start update(), Message Headder: " .. v[1])) -- 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
split_string2 = v
-- now we are processing a message, update the OBS Status display for Synchro (F9) with current settings. This is in case this is a Synchro event!
if synchro then
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source : " .. "F9_Function_Background_True"))
end
end
obs.obs_source_release(source)
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source : " .. "F9_Function_Background_False"))
end
end
obs.obs_source_release(source)
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source : " .. "F9_Function_Background_False"))
end
end
obs.obs_source_release(source)
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source : " .. "F9_Function_Background_True"))
end
end
obs.obs_source_release(source)
end -- end status update
local source = obs.obs_get_source_by_name("NoJudges") -- Display no 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
split_string2[32] = (" ")
obs.script_log(obs.LOG_INFO, string.format("Nil detected in Rank field (first round?)"))
end
eventComplete = false
local source = obs.obs_get_source_by_name("TVBanner2") -- enable text Source (TVBanner group) for display of dive/awards
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source at start of update(): " .. "TVBanner2 "))
end
end
obs.obs_source_release(source)
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source at start of update(): " .. event))
end
end
obs.obs_source_release(source)
-- end of Status display 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
tvBanner_removed = false -- as we are about to display dive data or awards!
-- 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
-- Divers country flag or club logo insert into source overlay.
local source = obs.obs_get_source_by_name("Flag")
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
-- 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
-- generate the Penalty text, if there is one
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
-- generate the main displays; diver & awards, etc
if synchro then -- >>>> *** If a SYNCHRO EVENT then process the data *** <<<<<
-- now generate lineone of the overlay, the Divers, preceded by rank
display1a = (" " .. split_string2[32] .. " ")
lineOne = string.insert(lineOne, display1a, 0)
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)
display1b = (" ")
--scores1 = split_string2[29]
if split_string2[17] ~= (" ") then -- if awards in J1 field then display them
sourcelineTwo = " " -- Empty string so nothing displayed and debug works correctly
local source = obs.obs_get_source_by_name("JudgeAwards") -- Enable awards Text Source group (else 11 individual text boxes to enable!)
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "Synchro JudgeAwards "))
end
end
obs.obs_source_release(source)
if split_string2[50] == "11" then -- 11 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 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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
-- 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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
-- 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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels11")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
-- 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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels9")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7")
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels5")
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
-- 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
-- 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)
end
obs.obs_source_release(source)
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)
end
obs.obs_source_release(source)
end
-- scores2 = split_string2[30] -- no data to put in this source as no awards
else -- Synchro before judge awards so display dive description and ranking, then
-- disable synchro judge awards, judgeLabels9 and judgeLabels11. Finally enable and display sourcelineTwo
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "Synchro JudgeAwards"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels5") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels9") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels11") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("Linetwo") -- Enable dive description
if source ~= nil then
obs.obs_source_set_enabled(source, true)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Enable_source: " .. "Linetwo "))
end
end
obs.obs_source_release(source)
--scores2 = (" ")
if split_string2[14] == "A" then position = (", straight")
elseif split_string2[14] == "B" then position = (", piked")
elseif split_string2[14] == "C" then position = (", tucked")
elseif split_string2[14] == "D" then position = (", free position")
end
if split_string2[16] == "5" or split_string2[16] == "7.5" or split_string2[16] == "10" then board = (" " .. split_string2[16] .. "m")
else board = (" ")
end
sourcelineTwo = (split_string2[61] .. position .. board) -- dive description + position
display2b = "!"
display2a = "!"
lineTwo = string.insert(lineTwo, sourcelineTwo, 0)
obs.timer_add( function() remove_TVbanner() end, dinterval ) -- hide overlay after timer period
end
-- >>>>> Individual event <<<<<<
else -- >>>> *** INDIVIDUAL EVENT so assume only 5 or 7 judges for individual events, rest of J fields must be 'blank'. Use awards line blank space for BannerLine2 data *** <<<<
-- generate lineone of the overlay, the Divers information, preceded by rank
display1a = (" " .. split_string2[32] .. " ")
lineOne = string.insert(lineOne, display1a, 0)
displayName = (split_string2[9]) -- display name and club
lineOne = string.insert(lineOne, displayName, 5)
display1b = (" ")
scores1 = split_string2[29]
if split_string2[25] ~= (" ") then -- then nothing in J9 award position so assume individual event and disable the 9 & 11 synchro judge role labels -- need to change to use UDP data with no of judges
-- should not have got to this point if Synchro but no harm in checking the awards to confirm!
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels11"))
end
end
obs.obs_source_release(source)
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)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels9"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels7") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels7"))
end
end
obs.obs_source_release(source)
local source = obs.obs_get_source_by_name("SynchroJLabels5") -- Disable synchro judge labels
if source ~= nil then
obs.obs_source_set_enabled(source, false)
if debug then
obs.script_log(obs.LOG_INFO, string.format("Disable_source: " .. "SynchroJLabels5"))
end
end
obs.obs_source_release(source)
end
if split_string2[17] ~= (" ") then -- if award in J1 position then display judge awards -- is there a better way of doing this now we have UDP data?
sourcelineTwo = (" ") -- empty sourcelineTwo field to ensure debug works correctly
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)
if debug then