Posted by member 212670 on 2006-10-10 17:03:56
-Should work with any xlabel, but mzscript syntax isn't compatible with all versions of mzscript.
-The site is wrapping stuff, so copy/paste in to your text editor for easier viewing.
*edit*
-Replace all NET with the 'not equal to' operator (less than and greater than symbols together - the site ate them).
timerX 50
timerY 50
timerWidth 146
timerHeight 24
timerSolidColors EEEEEE FFFFFF 000000
timerSolidBevelSize 1
timerText "02:00:15" ;can be set to the initial time before pressing go
timerFontAlign left
timerBorders 6 0 0 0
timerAlwaysOnTop true
*Label go
goX -84
goY 2
goWidth 40
goHeight 20
goSolidColors A6A6A6 FFFFFF 000000
goSolidBevelSize 1
goPressedSolidColors A6A6A6 000000 FFFFFF
goPressedSolidBevelSize 1
goText "go"
goOnLeftClick !start
*timerModuleHook !LabelLsBoxHook go
*Label stop
stopX -42
stopY 2
stopWidth 40
stopHeight 20
stopSolidColors A6A6A6 FFFFFF 000000
stopSolidBevelSize 1
stopPressedSolidColors A6A6A6 000000 FFFFFF
stopPressedSolidBevelSize 1
stopText "stop"
stopOnLeftClick !varset stop 1 ;important for stopping the timer
*timerModuleHook !LabelLsBoxHook stop
*Script bang !start
*Script exec !varset hrs 02 ;hours, likely set with %{args:1}
*Script exec !varset mins 00 ;mins, likely set with %{args:2}
*Script exec !varset secs 15 ;secs, likely set with %{args:3}
;set the vars to 00 if they aren't inputted above, otherwise, they'll be %{args:x}
*Script exec !IfExist [hrs] [][!varset hrs 00]
*Script exec !IfExist [mins] [][!varset mins 00]
*Script exec !IfExist [secs] [][!varset secs 00]
;determine whether mins starts at 59 which affects if an hour should be removed at start.
*Script exec !If ["%{mins}" = "59"] [!varset hrstog 1][!varset hrstog 0]
*Script label top
;if secs is 0, you want them to be 59. Otherwise, you just want - 1. Nested !ifs for leading 0s.
*Script exec !If ["%{secs}" = "0"] [!varset secs 59][!If ["%{secs}" < "11"][!varset secs 0%#%{secs} - 1%#][!varset secs %#%{secs} - 1%#]]
;if seconds are 59, you'll want to remove 1 from the minutes, if available. Nested !ifs for leading 0s.
*Script exec !If ["%{secs}" = "59"] [!If ["%{mins}" = "0"] [!If ["%{hrs}" NET "0"][!varset mins 59]][!If ["%{mins}" < "11"][!varset mins 0%#%{mins} - 1%#][!varset mins %#%{mins} - 1%#]]]
;if mins are 59, you'll want to remove 1 from hrs, if available. Nested !ifs are for leading 0s.
;Need to only run this once for the duration of mins = 59. Also, if mins starts at 59 this will be skipped.
*Script gotoif ["%{hrstog}" = "1"] skip
*Script exec !If ["%{mins}" = "59"] [!If ["%{hrs}" NET "0"] [!If ["%{hrs}" < "11"][!execute [!varset hrs 0%#%{hrs} - 1%#][!varset hrstog 1]][!execute [!varset hrs %#%{hrs} - 1%#][!varset hrstog 1]]]]
*Script label skip
*Script exec !If ["%{mins}" = "58"] [!varset hrstog 0]
;set the label's text
*Script exec !LabelSetText timer "%{hrs}:%{mins}:%{secs}"
*Script exec !pause 1000
*Script gotoif ["%{stop}" = "1"] done
*Script gotoif ["%{hrs}" = "0"] minscheck
*Script goto top
;if mins are 0, check if secs are 0, otherwise back to the loop.
*Script label minscheck
*Script gotoif ["%{mins}" = "0"] secondscheck
*Script goto top
;if mins are 0, secs will be checked. If they're 0, done, otherwise, back to the top.
*Script label secondscheck
*Script gotoif ["%{secs}" = "0"] done
*Script goto top
*Script label done
*Script exec !alert "finished or stopped!"
*Script exec !varset stop 0
*Script exec !varremove hrstog
*Script exec !varremove hrs
*Script exec !varremove mins
*Script exec !varremove secs
*Script ~bang