# Countdown Timer with optional next scene



## EmbodyWisdomToday (May 30, 2020)

EmbodyWisdomToday submitted a new resource:

Countdown Timer with optional next scene - When the timer reaches zero, either show text or change scenes



> Combining features from the default countdown.lua and the end-media-change-scene countdown timer, this script either shows text or forwards to a scene chosen from the list of scenes.  This script also has a seconds setting in addition to minutes.



Read more about this resource...


----------



## Lawrence_SoCal (Jun 4, 2020)

Can this handle multiple scenes (over a dozen)?
 I'm using Adv Scene Switcher to change scenes after media (recorded video) ends [working with developer now on some bugs]. I'd love to have a countdown timer.  But I need to program/configure over a dozen video endings with a scene change.


----------



## I3ordo (Jun 8, 2020)

This script has also less digits so my 5 minute counter does show unnecessary zeroes. eg: "4:30" instead of "00:04:30" and the next scene feature is quite welcome


----------



## EmbodyWisdomToday (Jun 17, 2020)

Lawrence_SoCal said:


> Can this handle multiple scenes (over a dozen)?
> I'm using Adv Scene Switcher to change scenes after media (recorded video) ends [working with developer now on some bugs]. I'd love to have a countdown timer.  But I need to program/configure over a dozen video endings with a scene change.


The script lists all the scenes of the scene collection in a dropdown.  Only one can be selected as next.

I copy and paste the script once for each scene that I want to forward to another scene when the timer is complete.  (Very easy to add a batch of scripts into a scene collection.)

Each script allows for setting the minutes and seconds to count down, which text field to have the countdown in, and which scene is next.  Scenes can form a linked list -- one to the next to the next -- which is why I adapted it.  I create about 25 to 35 scenes that comprise a 30-minute Feldenkrais Method / Micro Yoga Zen lesson, where each scene describes what to do.  The timer displays how long.  The script auto-forwards at 0:00.  I get the pleasure of clicking Record and then Stop Recording 30 minutes later.

Hopefully this description of what the script can do will help you decide if it's a fit for your objective.  
If you know how the long your videos are, set the countdown timer to their length.  This script sounds like it'd replace what you're using.  This script is less intelligent in terms of looking at the state of any media.  It only works off a pre-defined time.  If you update the media to be shorter or longer, you'd need to adjust the timer's values also.


----------



## EmbodyWisdomToday (Jun 17, 2020)

I3ordo said:


> This script has also less digits so my 5 minute counter does show unnecessary zeroes. eg: "4:30" instead of "00:04:30" and the next scene feature is quite welcome


Hi l3ordo, glad you like it.  If you ever need to update the output format, line 19 is where you do it:

```
local text          = string.format("%01d:%02d", minutes, seconds)
```
d stands for digits.  01 means show one digit with an unused padded 0 to the left, whoops, 
and 02 means show a 0 if the value is < 10.  The : is literal.  The % means fill with a variable mentioned later, in order of the %.

Hope that helps.  It's good fun.


----------



## EmbodyWisdomToday (Jun 17, 2020)

I3ordo said:


> the next scene feature is quite welcome


I'm looking at how to have a Next Scene option that would be the next scene in the scene collection.  The slightly tedious task of assigning the scene could then be eliminated.  Once you find your own, goto the next in order...

Have you done anything like that?  I found this but need to research how to know the current scene's name/id to compare:

```
if cur_seconds < 1 then
if next_scene = "-Next-" then // new value for automatically forwarding to next scene in collection
struct obs_frontend_source_list scenes;
obs_frontend_get_scenes(&scenes);
for (size_t i = 0; i < scenes.num; i++) {
        // making this up
        if current_scene.name = scenes[i].name then
               obs.obs_frontend_set_current_scene(scenes[i+1].name)
}
obs_frontend_source_list_free(&scenes);
```


----------



## PedenPants (Jun 18, 2020)

Thanks for this @EmbodyWisdomToday - it appears to work very well and I will try it on my next stream! ;)


----------



## rantanplan (Sep 15, 2020)

Hey. Thanks a lot! Nice Timer. As I am not a script kid ... can you give me a hint, how to extend the script to show days? Unfortunately I need a 5 day countdown ... is it "just" the output in line 19? Or do I have to do more?


----------



## EmbodyWisdomToday (Sep 22, 2020)

EmbodyWisdomToday updated Countdown Timer with optional next scene with a new update entry:

Countdown Timer (days+hours) with Optional Next Scene



> Added days and hours.
> Cleaned up Description.
> 
> For those wanting only minutes and seconds, change line 21 and remove "%01d:%02d:".  Then if you want the minutes to not have a leading zero, change the first '%02d' to '%01d'.



Read the rest of this update entry...


----------



## teekay1959 (Jan 18, 2021)

Hi EmbodyWisdomToday, thanks for creating this countdown timer. I'm especially interested in the "optional next scene" feature. Question for you. Does this countdown timer allow me to set countdown to a specific time? For example, to 7:30?


----------



## diefeuerlilie (May 2, 2021)

Great script. The one I searched long time for. Thank you. But I have a little problem with my font. The last digit is a bit cut. The surrounding box has not enough space at the end with this font


----------



## jpugarte1 (Jul 8, 2021)

Great script, thank you. I was wondering if it would be possible to add conditional branching. Something like "if current scene starts with [char], switch to scene_A; else, switcj to scene_B". I modified the script a little bit to change the properties and interface in the scripts window, but I'm not able to obtain the current scene name. Any ideas?


----------



## jocust10 (Sep 5, 2021)

It worked for a day and now - for the life of me - I cant get the countdown timer to come up. I tried everything.  It looks to me like the script is just not running anymore... is there a script debugger so i can at least see where the script is bombing out? There is supposed to be a "script log" but there are no instructions on how to activate it.  DOes anyone know how to activate the log so I can see if it is even executing the countdown timer with scene change option lua script?


----------



## Juliac (Sep 30, 2021)

jocust10 said:


> DOes anyone know how to activate the log so I can see if it is even executing the countdown timer with scene change option lua script?


Tools>Scripts opens a dialog box showing your loaded scripts. At the bottom right there is a button "Script Log" that opens it for me.


----------



## docos (Nov 25, 2021)

Hi , there is any way to put more than 366 days countdown?


----------



## alejandrorm1810 (Feb 6, 2022)

Is it possible to add a sound when timers end? checking forums lua doesnt have a sound system :(


----------



## coconutrice (Jun 11, 2022)

I've tried to use the script multiple times, but every time I get an error saying the following:
[CountdownDays.lua] Failed to call script_properties for obs_lua_script_get_properties: ...ata/obs-plugins/frontend-tools/scripts/CountdownDays.lua:121: attempt to call field 'obs_source_get_unversioned_id' (a nil value)

How can I fix this? Is this because I'm using a mac insteaad of a PC? Any help would be much appreicated!


----------



## coconutrice (Jun 11, 2022)

coconutrice said:


> I've tried to use the script multiple times, but every time I get an error saying the following:
> [CountdownDays.lua] Failed to call script_properties for obs_lua_script_get_properties: ...ata/obs-plugins/frontend-tools/scripts/CountdownDays.lua:121: attempt to call field 'obs_source_get_unversioned_id' (a nil value)
> 
> How can I fix this? Is this because I'm using a mac insteaad of a PC? Any help would be much appreicated!


I have figured it out! Just needed to download the latest version of OBS (mine was a few years old).


----------



## r3dd3vil (Sep 30, 2022)

Hello m8, tnx for the great plugin! One question Is It possibile to start a countdown based on an exactly date? For example i want a countdown that finish exactly tomorrow @ 3pm, Is It possibile?


----------



## BobRossLives (Oct 10, 2022)

When the countdown timer reaches zero, my scene changes with a stinger transition.  However, the stinger plays twice - it starts at countdown of zero, plays again from the beginning about .25 seconds into the stinger, and ends abruptly.  This doesn't happen when I manually select the scene - the stinger plays normally.  Anyone else have this happening?  I'm still on OBS 27.2.4 and not looking to go to 28.


----------

