Page 1 of 1

Counting up on a timer

Posted: Thu Apr 23, 2015 8:57 pm
by razac920
Here's a neat little trick to get timers to count upwards from zero instead of down to zero:
SetTimerRate("timername", -1)
I don't know if you will be able to start it if the timer is currently set to exactly zero, but I can confirm it works if you start it at 1 second, and I presume it would work if you started it to some small nonzero fraction, like
SetTimerValue("timername", 0.01)

I don't know if this is news to people, but I haven't found any posts about it, and I imagine it can be useful for survival/wave game modes and race modes.

Re: Counting up on a timer

Posted: Thu Apr 23, 2015 10:05 pm
by Noobasaurus
Neato. I was going to something similar soon in a map of mine by having one timer count down from 1, and each time it hits one it would set the visual timer to one more second that it was. This will be quite useful. Wonderful find, as usual!

Re: Counting up on a timer

Posted: Thu Apr 23, 2015 10:11 pm
by razac920
Yeah that was my original thought too, but this is much more efficient :)

Re: Counting up on a timer

Posted: Fri Apr 24, 2015 1:40 am
by jedimoose32
Good find - I could have sworn I read something about this in the documentation, but I could be crazy. Either way thanks for bringing it out in the open. Could be used for some kind of survival challenge game mode - the player's score is proportional to the value of an upwards-counting timer.

Re: Counting up on a timer

Posted: Fri Apr 24, 2015 9:40 am
by Marth8880
Neat find! :thumbs:

Could we get this nifty little find on the FAQ? :o