This Lua script is used in conjunction with VoiceMacro voice command software, and VMRemote.exe, and bat files to synchronize my VM variables when either the Replay buffer button is started or stopped. (https://www.voicemacro.net/documentation/#RemoteControl_VoiceMacro)
The issue is that when I click Start Replay Buffer, the BAT file associated with it runs, and a few seconds later, my other BAT file, which is supposed to run when I click Stop Replay Buffer, also runs. The end result is that the replay buffer does not start. I'm new to OBS and Lua, only a few days, so I have no idea where the problem may lie. Any help would be greatly appreciated.
Note: I did try a powershell script by modifying line 35: "(*.exe *.bat *.sh);" with *.ps1 in another version, but those.ps1 files would not work independently; the two bat files do work independently when clicking on them.
The issue is that when I click Start Replay Buffer, the BAT file associated with it runs, and a few seconds later, my other BAT file, which is supposed to run when I click Stop Replay Buffer, also runs. The end result is that the replay buffer does not start. I'm new to OBS and Lua, only a few days, so I have no idea where the problem may lie. Any help would be greatly appreciated.
Note: I did try a powershell script by modifying line 35: "(*.exe *.bat *.sh);" with *.ps1 in another version, but those.ps1 files would not work independently; the two bat files do work independently when clicking on them.
Lua:
obs = obslua
start_script_name = ""
end_script_name = ""
-- This Lua script is used in conjunction with VoiceMacro, VMRemote.exe, and bat files to synchronize my VM variables when either the Replay buffer button is started or stopped. (https://www.voicemacro.net/documentation/#RemoteControl_VoiceMacro)
function on_event(event)
if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED then
if start_script_name ~= "start_script" then
obs.script_log(obs.LOG_INFO, "executing " .. start_script_name)
os.execute(start_script_name)
end
end
if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED then
if end_script_name ~= "end_script" then
obs.script_log(obs.LOG_INFO, "executing " .. end_script_name)
os.execute(end_script_name)
end
end
end
-----------------------------------------------------------------------------------------------------
function script_update(settings)
start_script_name = obs.obs_data_get_string(settings, "start_script_name")
end_script_name = obs.obs_data_get_string(settings, "end_script_name")
end
function script_description()
return "run a script / executable when the stream starts or ends"
end
function script_properties()
props = obs.obs_properties_create()
obs.obs_properties_add_path(props, "start_script_name", "Start Buffer", obs.OBS_PATH_FILE, "(*.exe *.bat *.sh);;(*.*)", NULL)
obs.obs_properties_add_path(props, "end_script_name", "End Buffer", obs.OBS_PATH_FILE, "(*.exe *.bat *.sh);;(*.*)", NULL)
return props
end
function script_defaults(settings)
obs.obs_data_set_default_string(settings, "start_script_name", "start_script")
obs.obs_data_set_default_string(settings, "end_script_name", "end_script")
end
function script_load(settings)
obs.obs_frontend_add_event_callback(on_event)
end
-- This Lua script was is an adaptation of ntoff work, streamcmd.lua
-- Credits: (https://github.com/ntoff/obs_scripts/blob/master/streamcmd.lua)
-- Thank you!