Here's an example with lots of comments. It basically uses unit conversion factors (converting miliseconds to hours, etc.) to figure divide up the time. Hopefully the comments explain it well enough:
Rem ***** Main Source File *****
sync on
backdrop on
color backdrop 0
set text font "Verdana"
set text size 14
` Set the timer to 0 hours, 0 minutes and 0 seconds to start.
MyTimer=0
` UNREM the next line to set the timer to 2 hours and 45 minutes instead.
` MyTimer=(2*60*60*1000)+(45*60*1000)
MyTimerSeconds=0
MyTimerMinutes=0
MyTimerHours=0
MyTimerFraction#=0.0
OldTimer=Timer()
do
`Increase the timer by the # of seconds that have passed.
inc MyTimer,(Timer()-OldTimer)
OldTimer=Timer()
set cursor 0,0
print "MyTimer (in miliseconds):"
print MyTimer
print " "
`Convert the # of miliseconds to the # of hours using unit conversion factors.
MyTimerFraction#=MyTimer*(1.0/1000.0)*(1.0/60.0)*(1.0/60.0) `x ms * (1s / 1000ms) * (1m / 60s) * (1h / 60m) <-- convert ms to hours
`Print the fraction to the screen:
print "MyTimerFraction# (contains hours, minutes and seconds in the form of hours): ",MyTimerFraction#
`Get the # of hours. I'm using INT to round down and leave the decimals alone.
MyTimerHours = int(MyTimerFraction#)
`Subtract the # of hours so we just have minutes and seconds left.
dec MyTimerFraction#,MyTimerHours
`Print the fraction to the screen:
print "MyTimerFraction# (contains minutes and seconds in the form of hours): ",MyTimerFraction#
`Get the number of minutes. We multiply by 60 because right now we have the # of minutes in "fraction of an hour" form (ex. 30 mins is 0.5 hours). Multiplying by 60 gives us the number of minutes, since there are 60 minutes in an hour (ex. 0.5 hours x 60 = 30 mins).
MyTimerMinutes= int( (MyTimerFraction#)*60.0 ) `60 minutes in an hour
`Convert the # of minutes to hours and subtract that. Now only seconds and fractions of a second are left.
dec MyTimerFraction#,MyTimerMinutes*(1/60.0)
`Print the fraction to the screen:
print "MyTimerFraction# (contains seconds in the form of hours): ",MyTimerFraction#
`Get the # of seconds. We're ignoring the # of deciseconds, centiseconds, etc. (fractions of a second). We just want seconds for now.
`We multiply be 3600 because right now we have the # of seconds in "fraction of an hour" form. Since there are 3600 seconds in an hour, we multiply by 3600 to get the # of seconds.
MyTimerSeconds= int( (MyTimerFraction#)*3600.0 ) `3600 seconds in an hour
print " "
print "FINAL TIME (hours : minutes : seconds):"
print MyTimerHours," : ",MyTimerMinutes," : ",MyTimerSeconds
sync
loop
<--- (Contains helpful comments)
It's not as long as it looks...
MyTimer=9900000 `# of miliseconds in 2 hours and 45 minutes
MyTimerSeconds=0
MyTimerMinutes=0
MyTimerHours=0
MyTimerFraction#=0.0
OldTimer=Timer()
do
cls
inc MyTimer,(Timer()-OldTimer)
OldTimer=Timer()
MyTimerFraction#=MyTimer*(1.0/1000.0)*(1.0/60.0)*(1.0/60.0)
MyTimerHours = int(MyTimerFraction#)
dec MyTimerFraction#,MyTimerHours
MyTimerMinutes= int( (MyTimerFraction#)*60.0 )
dec MyTimerFraction#,MyTimerMinutes*(1/60.0)
MyTimerSeconds= int( (MyTimerFraction#)*3600.0 )
set cursor 0,0
print MyTimerHours," : ",MyTimerMinutes," : ",MyTimerSeconds
loop
<--- (Same as above but without almost no comments at all)
Guns, cinematics, stealth, items and more!