A code that allows timer function to stop after making a decision

Hello, this is La-Laker. I want to thank manowar for this code.

[[Link-01]]:
setTimeout(function(){ squiffy.story.go("Link-02"); }, 5000);
After 5 secs will automatically take you to Link 02
[[Link-02]]:
Your time is up.

But, I need more help. What is the proper code for the timer function to cease after picking a selection?

[[Link-01]]:
setTimeout(function(){ squiffy.story.go("Link-02"); }, 5000);
After 5 secs will automatically take you to Link 02

[[Decision A]]
[[Decision B]]

[[Link-02]]:
Your time is up.


It's exactly the same question I wanted to ask. It would double the chances to use the timer in the most effective way. I hope someone has an answer.


K.V.

Hello,

I've been trying to find out how to do this, as well.

Then, I saw this thread, and I found this:

https://www.w3schools.com/Jsref/met_win_cleartimeout.asp

Which helped me learn to do this:

@title clear_timeout

[[Link-01]]:
    squiffy.myVar = setTimeout(function(){ squiffy.story.go("Link-02"); }, 5000);
    setTimeout(squiffy.myVar);
    
After 5 secs will automatically take you to Link 02

[[DECISION 1]](Link-02)

[[DECISION 2]](Link-03)

[[Link-02]]:
    clearTimeout(squiffy.myVar);
    
Your time is up.


[[Link-03]]:
    clearTimeout(squiffy.myVar);


I made this one up for this example.

Enjoy!


Thanks, K.V. That helps a lot! I'll give this code a shot.


K.V.

Thanks, K.V. That helps a lot! I'll give this code a shot.

šŸ‘ KV likes this.


You're welcome! It's no problem!


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums