Yo. Uncle Despain here, with my newest RPG Maker VX Ace tutorial. Last time around, we made a bank where the player is able to store and withdraw gold. A lot of people have been asking about adding interest, so today’s tutorial will explain a way to do that. And more!
What we’re going to learn today is how to track time in common events. It’s easier than you might imagine—in fact, it’s super simple. The important thing about the idea is what to do with it.
When you can track the passage of time, you can add a tremendous amount of interesting mechanics to your game. I mentioned interest for your bank. You can expand the same idea for all sorts of other things—growing plants for a farm/planting system, items that level up as time passes. A day/night system, or weather, or seasons. All of these mechanics are possible with a simple common event that allows the game to keep track of time.
So let’s take a look. This is the most basic way to accomplish the idea.
(click for full view)
Ridiculously easy, right? As simple as this event is, let’s take a moment to look at what it does.
You understand how common events work—we went over those in a previous tutorial. So we know that this event will continually run in the background while the player is exploring your game world.
Every ten seconds, this event increases a variable. In this example, the variable is called “Hours”, but it can be anything you want. Don’t feel the need to measure time in longer “hours”—even if that’s what you name your variable, the player doesn’t see it. We’re just tracking time, and I smaller increments allows for more accurate tracking. You’ll see that, in this example, we wait ten seconds before an “hour” passes.
Of course, that amount of time can be changed—you might want to wait a minute, or more. All you’ve got to do is add more wait commands. Remember that one frame is one sixtieth of a second, so a sixty-frame wait will be about one second.
This is the only most basic way of tracking time. You might want to add a little more depth to the idea, so let’s consider tracking minutes and hours together.
This version uses two variables. If you understand conditional branches, it’s pretty straightforward. Every sixty frames (every second), the event goes into a conditional branch. If sixty minutes have passed, it adds to the hour variable and resets the minute counter. If not, it adds a minute. In this version, a “minute” passes every second, and an hour passes every sixty seconds. You might want to change that for your game—it’s just a matter of changing the number in the conditional branch, or changing the wait commands.
That’s all it takes to track time in your game. The parallel process common event will continually loop in the background of your game. Remember that you can turn it off with its Condition Switch, so you can make sure that time doesn’t pass when your player is in a cutscene. Just remember to turn it back on afterwards.
“Sure, that’s cool”, you say. “But what do I do with it?”
In my next tutorial, we’ll dive a little deeper. We’ll make a simple day/night system, and we’ll add interest to our bank account every day that passes. Stay tuned. And happy game making. 🙂