Skip to content

Commit 886981a

Browse files
committed
Improved obs startup. Bugfix
1 parent 7c4f16a commit 886981a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

obs-zoom-to-mouse.lua

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,10 +1148,8 @@ function on_settings_modified(props, prop, settings)
11481148
end
11491149
end
11501150

1151-
if auto_start then
1152-
on_toggle_zoom(true, true)
1153-
else
1154-
on_toggle_zoom(true, false)
1151+
if auto_start ~= nil then
1152+
on_toggle_zoom(true, auto_start)
11551153
end
11561154
return false
11571155
end
@@ -1578,10 +1576,20 @@ function script_update(settings)
15781576
start_server()
15791577
end
15801578

1581-
if auto_start then
1582-
on_toggle_zoom(true, true)
1583-
else
1584-
on_toggle_zoom(true, false)
1579+
if auto_start ~= nil and source == nil then
1580+
local timer_interval = math.floor(obs.obs_get_frame_interval_ns() / 100000)
1581+
obs.timer_add(wait_for_auto_start, timer_interval)
1582+
elseif auto_start ~= nil and source ~= nil then
1583+
on_toggle_zoom(true, auto_start)
1584+
end
1585+
end
1586+
1587+
function wait_for_auto_start()
1588+
local found_source = obs.obs_get_source_by_name(source_name)
1589+
if found_source ~= nil then
1590+
source = found_source
1591+
on_toggle_zoom(true, auto_start)
1592+
obs.remove_current_callback()
15851593
end
15861594
end
15871595

0 commit comments

Comments
 (0)