11obs = obslua
22
33function script_description ()
4- return [[ Saves replays to sub-folders using the Game Capture executable name.
4+ return [[ Saves replays to sub-folders using the current fullscreen video game executable name.
55
66Author: redraskal]]
77end
88
99function script_load ()
10+ ffi = require (" ffi" )
11+ ffi .cdef [[
12+ int get_running_fullscreen_game_path (char * buffer , int bufferSize )
13+ ]]
14+ detect_game = ffi.load(script_path () .. "detect_game.dll")
15+ print(get_running_game_title ())
1016 obs.obs_frontend_add_event_callback(obs_frontend_callback )
11- folder = get_running_game_title ()
1217end
1318
1419function obs_frontend_callback(event )
15- if event == obs .OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED then
16- folder = get_running_game_title ()
17- end
1820 if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED then
1921 local path = get_replay_buffer_output()
22+ local folder = get_running_game_title()
2023 if path ~= nil and folder ~= nil then
2124 print(" Moving " .. path .. " to " .. folder )
2225 move(path , folder )
@@ -36,9 +39,12 @@ function get_replay_buffer_output()
3639end
3740
3841function get_running_game_title()
39- local handle = assert (io.popen (" detect_game" ))
40- local result = handle :read (" *all" )
41- handle :close ()
42+ local path = ffi.new(" char[?]" , 260 )
43+ local result = detect_game.get_running_fullscreen_game_path(path , 260 )
44+ if result ~= 0 then
45+ return nil
46+ end
47+ result = ffi.string(path )
4248 local len = #result
4349 if len == 0 then
4450 return nil
@@ -55,7 +61,6 @@ function get_running_game_title()
5561 end
5662 i = i + 1
5763 end
58- print (" Current running game: " .. title )
5964 return title
6065end
6166
0 commit comments