I need help with this problem:
I need to test some conditions. In 6 seconds you must enter the two values and press pass. If you do that the timer must be stopped else timer sends you back to the start.
The timer starts perfectly, you have enough time to enter but the clear function does not work.
Pleeeeaseee help.
[[test the 3 people]]:
@clear
A.S.A.I.! says: "To help me and to help yourself all three teams must be ready for this task! Choose if you are a [[teamleader]], [[team 1]] or [[team 2]]!
[[teamleader]]:
@clear
setTimeout(function() {
squiffy.story.go("test the 3 people");
}, 6000);
set("teamle", squiffy.getRndInteger(0,10));
Your random integer is: {teamle}.
What's team 1 code? Enter the code
What's team 2 code? Enter the code
Enter the codes and then press [[pass]].
[[pass]]:
clearTimeout();
clearTimeout
needs a parameter.
I would suggest something like:
squiffy.set("timer_id", setTimeout(function() {
squiffy.story.go("test the 3 people");
}, 6000));
followed by:
clearTimeout( squiffy.get("timer_id") );
The setTimeout
function returns a timer ID. You need to save this value if you want to clear the timer later. In this case, I think putting it into a Squiffy attribute is the quickest way to pass it from one section to another.
I should also note that if you want to use post code to show us without the forum mangling it, you need to surround it with a line of three backticks. Like this:
```
[[example]]:
// some code goes here
You can even put HTML here: <input type="submit" value="Click me!"/>
```
This makes your post a little easier to read.