-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointerCountTchoukballTime.lua
418 lines (368 loc) · 14.5 KB
/
PointerCountTchoukballTime.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
obs = obslua
player1_labelname = ""
player2_labelname = ""
period_labelname = ""
Player1Count = 0
Player2Count = 0
PeriodCount = 0
last_text = ""
stop_text = ""
activated = false
hotkey_id = obs.OBS_INVALID_HOTKEY_ID
hotkey_P1Inc = obs.OBS_INVALID_HOTKEY_ID
hotkey_P1Dec = obs.OBS_INVALID_HOTKEY_ID
hotkey_P2Inc = obs.OBS_INVALID_HOTKEY_ID
hotkey_P2Dec = obs.OBS_INVALID_HOTKEY_ID
hotkey_PeriodInc = obs.OBS_INVALID_HOTKEY_ID
hotkey_PeriodDec = obs.OBS_INVALID_HOTKEY_ID
-- Function to set the time text
function p1Inc(pressed)
if not pressed then
return
end
Player1Count = Player1Count + 1
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function p1Dec(pressed)
if not pressed then
return
end
Player1Count = Player1Count - 1
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function p2Inc(pressed)
if not pressed then
return
end
Player2Count = Player2Count + 1
local text = string.format("%02d", Player2Count)
local source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function p2Dec(pressed)
if not pressed then
return
end
Player2Count = Player2Count - 1
local text = string.format("%02d", Player2Count)
local source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function periodInc(pressed)
if not pressed then
return
end
PeriodCount = PeriodCount + 1
local text = string.format("%02d", PeriodCount)
local source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function periodDec(pressed)
if not pressed then
return
end
PeriodCount = PeriodCount - 1
local text = string.format("%02d", PeriodCount)
local source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
end
function reset(pressed)
if not pressed then
return
end
Player1Count = 0
Player2Count = 0
PeriodCount = 0
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings1 = obs.obs_data_create()
obs.obs_data_set_string(settings1, "text", text)
obs.obs_source_update(source, settings1)
obs.obs_data_release(settings1)
obs.obs_source_release(source)
end
text = string.format("%02d", Player2Count)
source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings2 = obs.obs_data_create()
obs.obs_data_set_string(settings2, "text", text)
obs.obs_source_update(source, settings2)
obs.obs_data_release(settings2)
obs.obs_source_release(source)
end
local text = string.format("%02d", PeriodCount)
local source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings3 = obs.obs_data_create()
obs.obs_data_set_string(settings3, "text", text)
obs.obs_source_update(source, settings3)
obs.obs_data_release(settings3)
obs.obs_source_release(source)
end
end
function reset_button_clicked(props, p)
Player1Count = 0
Player2Count = 0
PeriodCount = 0
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings1 = obs.obs_data_create()
obs.obs_data_set_string(settings1, "text", text)
obs.obs_source_update(source, settings1)
obs.obs_data_release(settings1)
obs.obs_source_release(source)
end
text = string.format("%02d", Player2Count)
source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings2 = obs.obs_data_create()
obs.obs_data_set_string(settings2, "text", text)
obs.obs_source_update(source, settings2)
obs.obs_data_release(settings2)
obs.obs_source_release(source)
end
text = string.format("%02d", PeriodCount)
source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings3 = obs.obs_data_create()
obs.obs_data_set_string(settings3, "text", text)
obs.obs_source_update(source, settings3)
obs.obs_data_release(settings3)
obs.obs_source_release(source)
end
return false
end
function p1Inc_button_clicked(props, p)
Player1Count = Player1Count + 1
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
function p1Dec_button_clicked(props, p)
Player1Count = Player1Count - 1
local text = string.format("%02d", Player1Count)
local source = obs.obs_get_source_by_name(player1_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
function p2Inc_button_clicked(props, p)
Player2Count = Player2Count + 1
local text = string.format("%02d", Player2Count)
local source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
function p2Dec_button_clicked(props, p)
Player2Count = Player2Count - 1
local text = string.format("%02d", Player2Count)
local source = obs.obs_get_source_by_name(player2_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
function periodInc_button_clicked(props, p)
PeriodCount = PeriodCount + 1
local text = string.format("%02d", PeriodCount)
local source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
function periodDec_button_clicked(props, p)
PeriodCount = PeriodCount - 1
local text = string.format("%02d", PeriodCount)
local source = obs.obs_get_source_by_name(period_labelname)
if source ~= nil then
local settings = obs.obs_data_create()
obs.obs_data_set_string(settings, "text", text)
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
obs.obs_source_release(source)
end
return false
end
----------------------------------------------------------
-- A function named script_properties defines the properties that the user
-- can change for the entire script module itself
function script_properties()
local props = obs.obs_properties_create()
local p1 = obs.obs_properties_add_list(props, "P1Label", "Player 1 Label", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
local p2 = obs.obs_properties_add_list(props, "P2Label", "Player 2 Label", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
local period = obs.obs_properties_add_list(props, "PeriodLabel", "Period Label", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
local sources = obs.obs_enum_sources()
if sources ~= nil then
for _, source in ipairs(sources) do
source_id = obs.obs_source_get_id(source)
if source_id == "text_gdiplus" or source_id == "text_ft2_source" then
local name = obs.obs_source_get_name(source)
obs.obs_property_list_add_string(p1, name, name)
obs.obs_property_list_add_string(p2, name, name)
obs.obs_property_list_add_string(period, name, name)
end
end
end
obs.source_list_release(sources)
obs.obs_properties_add_button(props, "reset_button", "Reset Timer", reset_button_clicked)
obs.obs_properties_add_button(props, "P1Inc_button", "P1++", p1Inc_button_clicked)
obs.obs_properties_add_button(props, "P1Dec_button", "P1--", p1Dec_button_clicked)
obs.obs_properties_add_button(props, "P2Inc_button", "P2++", p2Inc_button_clicked)
obs.obs_properties_add_button(props, "P2Dec_button", "P2--", p2Dec_button_clicked)
obs.obs_properties_add_button(props, "PeriodInc_button", "Period++", periodInc_button_clicked)
obs.obs_properties_add_button(props, "PeriodDec_button", "Period--", periodDec_button_clicked)
return props
end
-- A function named script_description returns the description shown to
-- the user
function script_description()
return "Mit Hilfe dieses Script kann man per Hotkeys einen Punktezähler für zwei Spieler steuern.\n\nMade by evildox"
end
-- A function named script_update will be called when settings are changed
function script_update(settings)
player1_labelname = obs.obs_data_get_string(settings, "P1Label")
player2_labelname = obs.obs_data_get_string(settings, "P2Label")
period_labelname = obs.obs_data_get_string(settings, "PeriodLabel")
reset(true)
end
-- A function named script_defaults will be called to set the default settings
function script_defaults(settings)
end
-- A function named script_save will be called when the script is saved
--
-- NOTE: This function is usually used for saving extra data (such as in this
-- case, a hotkey's save data). Settings set via the properties are saved
-- automatically.
function script_save(settings)
local hotkey_save_array = obs.obs_hotkey_save(hotkey_id)
obs.obs_data_set_array(settings, "Pointcounter.Reset", hotkey_save_array)
obs.obs_data_array_release(hotkey_save_array)
local hotkey_save_array2 = obs.obs_hotkey_save(hotkey_P1Inc)
obs.obs_data_set_array(settings, "Pointcounter.P1Inc", hotkey_save_array2)
obs.obs_data_array_release(hotkey_save_array2)
local hotkey_save_array3 = obs.obs_hotkey_save(hotkey_P1Dec)
obs.obs_data_set_array(settings, "Pointcounter.P1Dec", hotkey_save_array3)
obs.obs_data_array_release(hotkey_save_array3)
local hotkey_save_array4 = obs.obs_hotkey_save(hotkey_P2Inc)
obs.obs_data_set_array(settings, "Pointcounter.P2Inc", hotkey_save_array4)
obs.obs_data_array_release(hotkey_save_array4)
local hotkey_save_array5 = obs.obs_hotkey_save(hotkey_P2Dec)
obs.obs_data_set_array(settings, "Pointcounter.P2Dec", hotkey_save_array5)
obs.obs_data_array_release(hotkey_save_array5)
local hotkey_save_array6 = obs.obs_hotkey_save(hotkey_PeriodInc)
obs.obs_data_set_array(settings, "Pointcounter.PeriodInc", hotkey_save_array6)
obs.obs_data_array_release(hotkey_save_array6)
local hotkey_save_array7 = obs.obs_hotkey_save(hotkey_PeriodDec)
obs.obs_data_set_array(settings, "Pointcounter.PeriodDec", hotkey_save_array7)
obs.obs_data_array_release(hotkey_save_array7)
end
-- a function named script_load will be called on startup
function script_load(settings)
-- Connect hotkey and activation/deactivation signal callbacks
--
-- NOTE: These particular script callbacks do not necessarily have to
-- be disconnected, as callbacks will automatically destroy themselves
-- if the script is unloaded. So there's no real need to manually
-- disconnect callbacks that are intended to last until the script is
-- unloaded.
local sh = obs.obs_get_signal_handler()
obs.signal_handler_connect(sh, "source_activate", source_activated)
obs.signal_handler_connect(sh, "source_deactivate", source_deactivated)
hotkey_id = obs.obs_hotkey_register_frontend("Pointcounter.Reset", "Scorecounter-Reset", reset)
hotkey_P1Inc = obs.obs_hotkey_register_frontend("Pointcounter.P1Inc", "Scorecounter-Player 1++", p1Inc)
hotkey_P1Dec = obs.obs_hotkey_register_frontend("Pointcounter.P1Dec", "Scorecounter-Player 1--", p1Dec)
hotkey_P2Inc = obs.obs_hotkey_register_frontend("Pointcounter.P2Inc", "Scorecounter-Player 2++", p2Inc)
hotkey_P2Dec = obs.obs_hotkey_register_frontend("Pointcounter.P2Dec", "Scorecounter-Player 2--", p2Dec)
hotkey_PeriodInc = obs.obs_hotkey_register_frontend("Pointcounter.PeriodInc", "Scorecounter-Period ++", periodInc)
hotkey_PeriodDec = obs.obs_hotkey_register_frontend("Pointcounter.PeriodDec", "Scorecounter-Period --", periodDec)
local hotkey_save_array = obs.obs_data_get_array(settings, "Pointcounter.Reset")
obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
obs.obs_data_array_release(hotkey_save_array)
local hotkey_save_array1 = obs.obs_data_get_array(settings, "Pointcounter.P1Inc")
obs.obs_hotkey_load(hotkey_P1Inc, hotkey_save_array1)
obs.obs_data_array_release(hotkey_save_array1)
local hotkey_save_array2 = obs.obs_data_get_array(settings, "Pointcounter.P1Dec")
obs.obs_hotkey_load(hotkey_P1Dec, hotkey_save_array2)
obs.obs_data_array_release(hotkey_save_array2)
local hotkey_save_array3 = obs.obs_data_get_array(settings, "Pointcounter.P2Inc")
obs.obs_hotkey_load(hotkey_P2Inc, hotkey_save_array3)
obs.obs_data_array_release(hotkey_save_array3)
local hotkey_save_array4 = obs.obs_data_get_array(settings, "Pointcounter.P2Dec")
obs.obs_hotkey_load(hotkey_P2Dec, hotkey_save_array4)
obs.obs_data_array_release(hotkey_save_array4)
local hotkey_save_array5 = obs.obs_data_get_array(settings, "Pointcounter.PeriodInc")
obs.obs_hotkey_load(hotkey_PeriodInc, hotkey_save_array5)
obs.obs_data_array_release(hotkey_save_array5)
local hotkey_save_array6 = obs.obs_data_get_array(settings, "Pointcounter.PeriodDec")
obs.obs_hotkey_load(hotkey_PeriodDec, hotkey_save_array6)
obs.obs_data_array_release(hotkey_save_array6)
end