diff --git a/RandomStingerVideo/RandomStingerVideo.lua b/RandomStingerVideo/RandomStingerVideo.lua index 5eb9b82..35f425a 100644 --- a/RandomStingerVideo/RandomStingerVideo.lua +++ b/RandomStingerVideo/RandomStingerVideo.lua @@ -1,5 +1,5 @@ -- RANDOM STINGER VIDEO --- Version 1.03 +-- Version 1.04 -- "Imports" local obs = obslua local math = require 'math' @@ -120,15 +120,20 @@ function set_random_video_on_transition() obs.source_list_release(transitions) end +function delayed_update() + set_random_video_on_transition() + obs.timer_remove(delayed_update) +end + -- Built-in: raised on OBS events function on_event(event) -- When the scene has changed, set a new video to the transition source if event == obs.OBS_FRONTEND_EVENT_SCENE_CHANGED then - set_random_video_on_transition() + obs.timer_add(delayed_update, 1000) end end --- Built-in: Called when the script’s settings (if any) have been changed by the user. +-- Built-in: Called when the script's settings (if any) have been changed by the user. function script_update(settings) -- Read settings transitionName = obs.obs_data_get_string(settings, "transition") @@ -171,8 +176,12 @@ function script_load(settings) obs.obs_frontend_add_event_callback(on_event) end +function script_unload() + obs.timer_remove(delayed_update) +end + -- Built-in: Returns the script description. function script_description() return - "Randomly assigns a video to a stinger transition on scene change.\nAuthors: FineWolf , extraxterrestrial\nVersion: 1.03" + "Randomly assigns a video to a stinger transition on scene change.\nAuthors: FineWolf , extraxterrestrial\nVersion: 1.04" end