Skip to content

Commit c1411f1

Browse files
committed
Add stopOnLastImage to OBS lua settings script
1 parent 15fac8f commit c1411f1

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

RefreshImagesLua.lua

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,41 @@ minSlideDuration = 1000
1616
maxSlideDuration = 100000
1717

1818
function script_description()
19-
return "Script for the slideshow browser source. Saves a list of images in images/images.js, and saves settings in settings.js. See README for full details. " ..
20-
"Is run automatically when OBS is launched.\n\n" ..
19+
return "Lua script for the BrowserImageSlideshow. Updates the list of images in images/images.js, and overwrites the settings in settings.js. See README for full details. " ..
20+
"Runs once automatically when OBS is launched. \n\n" ..
2121

22-
"*** Whenever settings or images are updated, reload the script & refresh the browser to use updated settings/images: \n"..
23-
"- Reload script: press the reload button with this script selected.\n"..
24-
"- Refresh browser source: toggle the source's visiblity off and on\n"..
22+
"*** After changing the settings below, the script & browser source must be reloaded for changes to take effect: *** \n"..
23+
"1. Reload script: press the Reload Scripts button (next to Add/Remove scripts).\n"..
24+
"2. Refresh browser source: toggle the source's visiblity off and on\n"..
2525

2626
"\nModes: \n" ..
27-
"0: Random order\n" ..
28-
"1: Alphabetical order\n" ..
29-
"2: Alphabetical order (start at random image when source becomes visible)"
27+
"[0]: Random order\n" ..
28+
"[1]: Alphabetical order\n" ..
29+
"[2]: Alphabetical order (start at random image)\n\n"..
30+
31+
"https://obsproject.com/forum/resources/browser-image-slideshow.852/"
32+
3033
end
3134

3235
function script_properties()
3336
props = obs.obs_properties_create()
3437
obs.obs_properties_add_int(props, "mode", "Mode:", 0, 2, 1)
3538
obs.obs_properties_add_int(props, "slideDuration", "Slide duration (ms):", minSlideDuration, maxSlideDuration, 500)
39+
obs.obs_properties_add_bool(props, "stopOnLastImage", "Stop slideshow on last image?")
3640
return props
3741
end
3842

3943
-- called when script is loaded
4044
function script_load(settings)
4145
obs.obs_data_set_default_int(settings, "slideDuration", defaultSlideDuration)
42-
refresh_images()
46+
update_image_list(script_path() .. 'images/')
4347
end
4448

4549
-- called when script settings change
4650
function script_update(settings)
4751
mode = obs.obs_data_get_int(settings, "mode")
4852
slideDuration = obs.obs_data_get_int(settings, "slideDuration")
53+
stopOnLastImage = obs.obs_data_get_bool(settings, "stopOnLastImage")
4954
update_slideshow_settings()
5055
end
5156

@@ -55,7 +60,14 @@ function update_slideshow_settings()
5560

5661
output:write('let mode = '.. mode .. ';\n')
5762
output:write('let slideDuration = '.. slideDuration .. ';\n')
63+
if stopOnLastImage == true then
64+
output:write('let stopOnLastImage = true;\n')
65+
else
66+
output:write('let stopOnLastImage = false;\n')
67+
end
5868
output:close()
69+
70+
log_slideshow_info()
5971
end
6072

6173
-- write list of images to js file
@@ -76,7 +88,6 @@ function update_image_list(dir)
7688
output:close()
7789
end
7890

79-
function refresh_images()
80-
local list = update_image_list(script_path() .. 'images/')
81-
print("Refreshed images (images: ".. imageCount .." | mode: ".. mode .." | duration: ".. slideDuration .. ")")
91+
function log_slideshow_info()
92+
print("BrowserImageSlideshow updated. \n" .. "Files detected: ".. imageCount .." | mode: ".. mode .." | duration: ".. slideDuration .. "ms | loop: " .. tostring(not(stopOnLastImage)))
8293
end

0 commit comments

Comments
 (0)