Help on this pausable timer

I've successfully made the basics for a custom timer using the following script:

Debate Timer script pic

I have a LastUnpaused value that tracks the value that the global timer displayed when it was last unpaused. When the paused variable is set to true, this value is repeatedly updated to match the global timer.

How would I modify the math block in the Debate Timer script pic (1) block to take into account this value and make sure the timer continues from where it previously left off when the paused variable is switched to false?

Or is my method of pausing not a good one and should be swapped out for something else?

I wouldn't continually change the contents of your timer object, which means your timer needs continual maintenance. Instead, when you pause and unpause the timer, update the offset of your timer from the system timer.

There are a bunch of timer projects in the web site; the first one I found is here:
https://snap.berkeley.edu/snap/snap.html#present:Username=rdococ&ProjectName=Stopwatches&editMode&noRun
but it may be more complicated than you need because it allows for multiple timers.

So, change the name of your "TimeElapsed" variable to "TimeOffset" and start the timer by setting it equal to the value reported by TIMER. Change "LastUnpaused" to "LastPaused." Then, when pausing the timer, set LastPaused to TimeOffset; when unpausing, set TimeOffset to umm this takes some careful thinking, but I think it's
TimeOffset + (TIMER - LastPaused). Because when you want to know your timer value, you'll compute TIMER-TimeOffset, so pausing should increase the offset you'll later subtract from TIMER.

TL;DR: The values you store in your timer shouldn't be absolute times, but rather times relative to TIMER.

Thank you for your assistance. I solved it using something like this:
Debate Timer script pic (2)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.