Countdown Lua
Countdown Lua
source_name = ""
total_seconds = 0
cur_seconds = 0
last_text = ""
stop_text = ""
activated = false
hotkey_id = obs.OBS_INVALID_HOTKEY_ID
last_text = text
end
function timer_callback()
cur_seconds = cur_seconds - 1
if cur_seconds < 0 then
obs.remove_current_callback()
cur_seconds = 0
end
set_time_text()
end
function activate(activating)
if activated == activating then
return
end
activated = activating
if activating then
cur_seconds = total_seconds
set_time_text()
obs.timer_add(timer_callback, 1000)
else
obs.timer_remove(timer_callback)
end
end
function source_activated(cd)
activate_signal(cd, true)
end
function source_deactivated(cd)
activate_signal(cd, false)
end
function reset(pressed)
if not pressed then
return
end
activate(false)
local source = obs.obs_get_source_by_name(source_name)
if source ~= nil then
local active = obs.obs_source_active(source)
obs.obs_source_release(source)
activate(active)
end
end
function reset_button_clicked(props, p)
reset(true)
return false
end
----------------------------------------------------------
return props
end
reset(true)
end