Gw Temp

Menu

Tutorial - 'Nonstandard Timers' by Rast

An item about RPGMaker 2000 posted on

Blurb

Rast demonstrates how to create timers that count up and show hours and minutes instead of minutes and seconds.

Body

This tutorial is all about how to make RPGMaker's timers do things other that what they're supposed to. In other words, we're going to go over how to make timers that count up, and how to make timers that show hours and minutes rather than minutes and seconds.

Timers that count up

So, you need a timer that counts up. Lucky for you, this isn't hard. In fact, we only need one common event, one switch (TimerEnable), and two variables (TimerValue and Subticks) to make it all work.

Creating Event

Have the event creating the count-up timer set TimerValue to the number of seconds to start the timer at, Subticks to 1, then turn on TimerEnable.

Common Event (Timer Controller)

This is the event that causes the timer to count up. It is a parallel event that is turned on by the TimerEnable switch. It does the following:

1) Increment Subticks by 1.
2) If Subticks is 10 or higher, increment TimerValue by 1 and set Subticks back to 1.
3) Using the Timer Operations command, set the timer to TimerValue, and start the timer
4) Wait 0.1 seconds

As you can see, this event executes 10 times a second and increments TimerValue by 1 on every 10th pass. We do this because RPGMaker will still want to make the timer count down and we keep it from doing weird things by resetting it 10 times a second.

As long as TimerEnable is on, your timer will count up, and not down. The moment you turn TimerEnable off, your timer will start to count down, so make sure you stop or hide the timer as soon as you turn the switch off.

Timers that show time in HH:MM format

So, you've made your count-up timer, but you have a problem. After an hour and 40 minutes, it gets stuck at 99:99. An easy way around this is to modify your Timer Controller common event so it automatically kicks over to HH:MM format after an hour. This will let your timer run for 99 hours (almost 4 days!) before it maxes out.

Again, this isn't hard. Just replace step #3 above with these steps:

3a) If TimerValue is below 3600 (the number of seconds in an hour), do the original step 3.
3b) If it's above 3600, copy TimerValue into a scratch variable.
3c) Divide this value by 60
3d) Using the Timer Operation command, set the timer to the scratch value, and start the timer.

And now your timer shows hours and minutes instead of minutes and seconds. Your original seconds value remains unchanged and you can still do whatever with it.

Parting Words

Nothing hard here. This is most useful for timed minigames and such, but you could easily use this to add a stopwatch-style timer anywhere you need one. You can also easily modify this to create timers that count down (like normal), but shows hours and minutes instead of minutes and seconds, and you could also add another switch that would pause the counter by preventing TimerValue from being incremented.