Hidden Timer
DescriptionThis tutorial is aimed at teaching you how to create a time-conditioned event without using the default timer, as it shows up on the screen and that is sometimes undesirable. Additionally, this method allows you to have more than one timer running at the same time, so that is another helpful reason to use this method or some variation thereof.
Since this is really a very simple concept which is quite self-evident, the tutorial will be pretty prescriptive.
IngredientsThis tutorial uses two common events, one switch, and one variable. For the sake of this tutorial, I will pretend we are using Switch 1 and Variable 1, though you could use any switch and variable. Switch 1 will be named "Timer", while Variable 1 will be called "Timer in Seconds." The two common events will be called "Timer Start" and "Timer Update," respectively.
Please keep in mind that this is a more generalized explanation of the concept, and my intention is that you could easily adapt it to any situation in which you need a timer. As such, it is possible to do this without even common events or a switch if the timer is localized to a particular event or map. However, this tutorial is aimed at creating a general timer which can be reused in many different maps.
Directions- Make a common event and call it Timer Start. It should have no trigger and no condition switch. In that common event, have the following:
Name: [Timer Start] Trigger: [None] Condition Switch: [None]
@>Control Switches: [0001: Timer] = ON
@>Control Variables: [0001: Timer in Seconds] = 0
- Now make a second common event called Timer Update. It should have a trigger of Parallel Process and its condition switch should be Switch 1: Timer
Name: [Timer Update] Trigger: [Parallel] Condition Switch: [0001: Timer]
@>Wait: 60 frame(s)
@>Control Variables: [0001: Timer in Seconds] += 1
The number of frames to wait is set to 60 because there are 60 frames per second in RMVX and RMVX Ace, so all that is doing is adding 1 to the timer every second. If you are using XP, it should be 20 frames instead.
- All you need to do to start or reset the timer is to call the 1st common event like so:
@>Call Common Event: Timer Start
- You can check whether the timer has exceeded X seconds by:
@>Conditional Branch: Variable [0001: Timer in Seconds] >= X
- You can pause the timer with:
@>Control Switch: [0001: Timer] = OFF
You can unpause the timer with:
@>Control Switch: [0001: Timer] = ON
ExplanationAs you can see, it is very simple. In essence, the Timer Start common event simply resets the timer to 0 and turns on the switch which triggers the Timer Update common event. The Timer Update common event simply waits one second, adds 1 to the Timer variable, and then repeats. Truthfully, it is only the Timer Update common event which is central to the operation of this timer. You can create multiple timers simply by replicating this structure and using a different variable to count the seconds, though it might be a good idea to localize any timer operations to a single common event and use Conditional Branches to check which ones are supposed to be updating.
I think that anyone who understands variables can easily derive this or something similar. However, I wrote this tutorial since someone asked the question and it is a very simple illustration of one useful thing that variables can do.