I have a variable that counts down from 1000 to 0 in ten seconds. I also have a <<if $var is 0>> condition at the bottom of the page, however that only registers when the page loads in, and $var is at 1000.
Is there a check function or something I can do to make the program say "Hey, $var is now 0, you wanna run that bit of conditional code now?"
Any help would be greatly appreciated.
Edit: I'm aware reloading the page does that, but that would just reload the counter up to 1000, show the thing that should be available only when it's at 0... and basically break everything.
Comments
Why not add extra code to your background count-down code so that it updates the current page when it reaches zero?
I'm using a tweaked version of some code I was shown on here, to help with an earlier question. The code I have works exactly as desired, except for the purposes of this question, in which I'm having trouble implementing a "refresh" or a "check" on an if statement.
<<set $seconds to 10, $cnd to $seconds * 100>>
Countdown: <span id="countdown">$cnd</span> seconds remaining!
<<set $command to "<<timed 0.01s>>">>
<<for $i to 0; $i lt $cnd; $i++>>
<<set $command += "<<set $cnd -= 1>><<replace \"#countdown\">>$cnd<</replace>><<next>>">>
<</for>>
<<set $command += "<<replace \"#countdown\">>Too Late! <<set $check to 1>><</replace>><</timed>>">>
<<print $command>>
<if $check is 1>>
This bit of code will run
<</if>>
the variable $check is set to 0 before the code runs. When $cnd reaches 0, $check becomes 1, but the browser still has the <<if $check is 1>> bit of code to not run because it initially read it as a 0.
For example:
And then create a new "Too Late" passage and put everything in there. For example:
PS: Building a 1000 clause <<timed>> is horrific. I suppose that I need to create a repeatable macro in the same vein as <<timed>>.
You'll be able to use them to simplify the above construct to something like the following: