-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsave-replay.lua
More file actions
58 lines (50 loc) · 2 KB
/
save-replay.lua
File metadata and controls
58 lines (50 loc) · 2 KB
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
obs = obslua
source_name = ""
hotkey_id = obs.OBS_INVALID_HOTKEY_ID
attempts = 0
last_replay = ""
----------------------------------------------------------
-- The "Instant Replay" hotkey callback
function instant_replay(pressed)
if not pressed then
return
end
local replay_buffer = obs.obs_frontend_get_replay_buffer_output()
if replay_buffer ~= nil then
-- Call the procedure of the replay buffer named "get_last_replay" to
-- get the last replay created by the replay buffer
--local ph = obs.obs_output_get_proc_handler(replay_buffer)
--obs.proc_handler_call(ph, "save", nil)
obs.obs_frontend_replay_buffer_save()
obs.obs_output_release(replay_buffer)
else
obs.script_log(obs.LOG_WARNING, "Tried to save an instant replay, but found no active replay buffer!")
end
end
----------------------------------------------------------
-- A function named script_update will be called when settings are changed
function script_update(settings)
source_name = obs.obs_data_get_string(settings, "source")
end
-- A function named script_description returns the description shown to
-- the user
function script_description()
return "saves replay buffer"
end
-- A function named script_load will be called on startup
function script_load(settings)
hotkey_id = obs.obs_hotkey_register_frontend("instant_replay.trigger", "Save Replay Workaround", instant_replay)
local hotkey_save_array = obs.obs_data_get_array(settings, "instant_replay.trigger")
obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
obs.obs_data_array_release(hotkey_save_array)
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, "instant_replay.trigger", hotkey_save_array)
obs.obs_data_array_release(hotkey_save_array)
end