Use a single variable for your time that stores it represented as the total number of seconds.
Then you can show hours/minutes/seconds with this expression:
[[('x0' + Math.floor(Timer / 60 / 60)).slice(-2) ]]:[[('x0' + Math.floor(Timer / 60)).slice(-2) ]]:[[('x0' + Timer % 60).slice(-2)]]
(NOTE: the slice
and 'x0'
is to make sure there is a leading 0
if any of the units are a single digit number)
To count you just have to add 1 to your variable ever second. I would do this by adding a hidden widget and using an event like Move to add to the variable. Add a condition to check a different variable which will be toggled by your button so you can control whether the timer should stop or not. Then you have a separate case that fires the event again after 1 second. This is your timer.
OnMove
If variable StopCounter does not equal true
Set variable Timer to: [[Timer + 1]]
If true
Wait 1000ms
Fire event this widget Move
Then to top it all off you just need to make your button set StopCounter to “true” and the timer will stop. If you then change StopCounter to be “false” or nothing then it will start counting again.