Using UDP ports in OBS Lua

andy5211d

New Member
If there is anyone following this thread, a working version of the dive recording TV Overlay script is now available on GitHub. Version V3.x.x uses UDP communications exclusively and at present only one UDP port. It is likely that more message's from other ports will be added as we get experience in using the software for the national and regional competitions. Search GitHub for DR2TVOverlay and the script should be found.
 

andy5211d

New Member
Something is wrong, trying to post a new thread about hotkeys but don't have the correct privileges! Will add to this thread in the hope someone can give me a clue as to what I'm doing wrong:

Using Lua to assign hotkeys and all works as expected. Now need to use a key modifier, in my case Ctrl, and thought this was an easy add but no does not register any hotkey with a Ctrl modifier. This is the code snippet with the extra hotkey as key_9

Code:
-- Hotkey definitions and default settings
hk = {}
key_1 = '{ "htk_1": [ { "key": "OBS_KEY_F1" } ], '   -- HK to temp remove_overlays
key_2 = '  "htk_2": [ { "key": "OBS_KEY_F2" } ], '   -- HK to temp display_overlays (all of them)
key_3 = '  "htk_3": [ { "key": "OBS_KEY_F3" } ], '   -- HK to redisplay_overlays
key_4 = '  "htk_4": [ { "key": "OBS_KEY_F12" } ], '   -- HK to toggle_event_position
key_5 = '  "htk_5": [ { "key": "OBS_KEY_F9" } ], '   -- HK to toggle_event_type (synchro or individual)
key_6 = '  "htk_6": [ { "key": "OBS_KEY_F5" } ], '   -- HK to permanently remove overlays
key_7 = '  "htk_7": [ { "key": "OBS_KEY_F8" } ], '   -- HK to disable auto-hide of overlays
key_8 = '  "htk_8": [ { "key": "OBS_KEY_F10" } ], '   -- HK to toggle Event A or Event B
key_9 = '  "htk_9": [ { "key": "OBS_KEY_Ctrl+F12" } ] } '   -- HK to toggle simultaneous events mode
json_s = key_1 .. key_2 .. key_3 .. key_4 .. key_5 .. key_6 .. key_7 .. key_8 .. key_9
default_hotkeys =
    {
    {id='htk_1', des='Temporary Remove DR2TVOverlays ',   callback=remove_overlays},
    {id='htk_2', des='Temporary Display All DR2TVOverlays ',  callback=display_overlays},
    {id='htk_3', des='Re-display Overlays ',  callback=redisplay_overlays},
    {id='htk_4', des='Toggle Event Overlay Position ',   callback=toggle_event_position},
    {id='htk_5', des='Toggle Event Type (Synchro or Individual) ',   callback=toggle_event_type},
    {id='htk_6', des='Permanently Remove All Overlays ', callback=toggle_display_disable},
    {id='htk_7', des='Disable Auto-hide of Overlays ', callback=toggle_disable_of_autohide},
    {id='htk_8', des='Toggle to Display Event A or Event B ', callback=toggle_event_a_or_b},
    {id='htk_9', des='Toggle to/from Simultanious Event Overlays ', callback=toggle_simultaneous_events},
    }

-- The function named "script_load" will be called on startup
function script_load(settings)
    s = obs.obs_data_create_from_json(json_s)
    for _,v in pairs(default_hotkeys) do
      a = obs.obs_data_get_array(s,v.id)
      h = obs.obs_hotkey_register_frontend(v.id,v.des,v.callback)
      obs.obs_hotkey_load(h,a)
      obs.obs_data_array_release(a)
    end
    obs.obs_data_release(s)

As best I can tell the problem is this statement: key_9 = ' "htk_9": [ { "key": "OBS_KEY_Ctrl+F12" } ] } ' as the 'OBS_KEY_Ctrl+F12' part is not recognised by OBS as a valid key combination. If I replace this with say 'OBS_KEY_F4' it works as expected. I expect its a very simple fix but so far it has alluded me. Thanks.
 
Top