0 votes
by (140 points)
Hi, I have a timer that works even when the game is shut. Once the time expires it goes to the desired passage. The issue is that the timer stays at zero if I go to the passage again. I want the timer to restart once the go-to is executed so that if I visit the passage again it executes itself again. Any help will be really appreciated.  Here is the code -


<span id="countdown"></span>

<<if $afterTwoHours == null>>

<<set $afterTwoHours = new Date()>>

<<set $afterTwoHours.setHours($afterTwoHours.getHours()+2) >>

<<remember $afterTwoHours>>


<<silently>> <<repeat 1s>>

<<set $now = new Date()>>

<<set $seconds = Math.floor(($afterTwoHours - $now) / 1000)>>

<<if $seconds > 0>>

<<replace "#countdown">>You can scan again in $seconds seconds.<</replace>>


<<goto "Start">> <<stop>> <</if>>

<</repeat>> <</silently>>

Please log in or register to answer this question.