The RPG Maker Resource Kit

RMRK RPG Maker Creation => General Tutorials and Eventing => RPG Maker General => Tutorials Database => Topic started by: modern algebra on April 22, 2012, 01:29:03 PM

Title: [XP/VX/VXA] Hidden Timer
Post by: modern algebra on April 22, 2012, 01:29:03 PM
Hidden Timer


Description
This 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.

Ingredients
This 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

Explanation
As 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.