Home
Sitemap
Site News
Downloads
FAQ
Contact
• Basic Tutorials •
Maps
The Database
Events
Graphic Resources
• More Advanced Tutorials •
Maps
Events
The Database
Event Systems
• RGSS •
Script Fixes
Script Systems
• Other •
Using RMXP
Mini Tutorials
Miscellaneous
• Reference •
Reference

In this tutorial you will learn...

• About timers in events
• How they can be useful
• How to use them successfully

Now, you may not think that timers require a lot of explaining - but, believe me, they are more tricky to use than they sound! So, in this tutorial, I will go through making a basic system that uses a timer. Also, with this, you'll have a chance to use some Common Events too, and become familiar with those. Basically, in this event system, I will make a lantern that runs out of oil after a certain time. (I'll write an add-on to this tutorial later on which tells you how to incorporate buyable lantern oil items that refill the lantern etc. - but I haven't quite got there yet!)

Firstly, open up your project and get a clear map, and on that map, double click to make a new event. In the conditions section, set it to having a switch on, called Lantern or something similar. Now, set the trigger to parallel and in the commands section, right click and click insert, and find the Control Timer command, which is below the Control Self Switch button. When you click on that, you'll get this box...



Now, this is pretty self-explanatory: the operation section controls whether the timer is started or stopped (if you select stop without having started a previous timer, nothing happens), and the boxes below state how long the timer should run for. In this example, set it to about ten seconds - it makes testing it easier, and we can always change it later.

Now, underneath the Control Timer command, add a Control Switch command, turning a new switch on - call it Timer. That's it for the first page; it should look something like the following...



Okay, so now we need to add another page to our event. On this page, set the trigger to parallel, and in the conditions area, set the condition to switch Timer being on. Then, in the commands section, insert a conditional branch. When you get to the conditional branch window, select the bottom option - when Timer is … or … . In that box, put in when Timer is 0 sec. or less (it should be fewer, but that's Japanese traslation for you!), and then uncheck the box at the bottom of the window. Press OK. You see what we're doing here? You've just made a very basic parallel system - something I specialise in! Basically, because this event has a parallel trigger, it will keep checking the conditions until they are true, without freezing the map as an autorun event would. In this case, the game will keep checking to see what the timer is, and when it gets to 0 seconds, it will execute the commands that we put in the conditional branch.

We'll put something actually inside the conditional branch later. Your second page of event commands should look something like this...



Now, after that, we'll have a little go at using common events. Open your database by selecting it from the menu or pressing F9 on your keyboard. Head over to the Common Events tab, and select a blank one (if you haven't done so already). Common events, as I quickly described in one of my lengthly database tutorials, are events that can be accessed from anywhere in the game, no matter what map you are on. Because of this, you can't use event- or map-dependant commands like Set Move Route, etc. Also, you cannot have Action Button triggers, obviously, because there is no event on the map. The only way to control Common Events is to either use a switch from within the event on the map where you need it, or call the Common Event from an event on the map (we'll be doing this later on).

Now, leave the trigger and the condition boxes blank. In the command section, we're going to put all the commands for when the lantern runs out of oil. So, because we haven't actually set up the whole lantern system yet, I'll just have to put in some temporary commands that will show us if the timer is running or not. As I said, I'll write a complete tutorial on laterns and oil in the Other tutorial section. So, once you've done this, you need to add a command at the bottom of the common event which turns the Timer switch back off again. This will bring us back to the page on the map event where the timer is started up. Your common event should now look like this...



Once you've done this, we need to do one last thing. You remember that I said we'd put something in the conditional branch later? Well, we need to call the common event that we've just created from inside that conditional branch. This is what I was going on about earlier. Head back to the second page of your event on the map, and inside the conditional branch, insert an event command. Now, the Call Common Event command that we need is on the first page, third up from the bottom. Click it, and select the common event that you just made, like so...



Now you're ready to try out your system! First, you need to make a placeholder event to turn the initial Lantern switch on, which, eventually, will be done by the Lantern Item itself. So, now you should have your map event, your common event, and your placeholder event which turns on the switch to activate your timer in the first place. Got that? Sorry if that was a bit confusing! Anyway, try out your system. Every ten seconds, your common event commands should execute - in my case, the message will show up, like this...



Then, once I've cancelled the message (that is, the common event commands have stopped), the timer will restart from the Timer switch being turned off again. Good, eh? And because we've controlled everything with switches, we can control when the timer stops and starts, with the Lantern switch, and we can control the executed event commands all at once using the common event. Handy system, don't you think?

Well, that's pretty much it for this tutorial - hopefully you've begun to understand timers a bit, and how they work. They're not as simple as they sound! My next tutorial will be on something that I haven't decided yet! If you want a more complete continuation of the Lantern Oil tutorial, head over to the Event systems section via the menu or the Sitemap. See you there!

:: << Previous Tutorial ::      :: Home ::      :: Skip Ahead to Tutorial VI >> ::

RPG Maker XP © 2005 Enterbrain Inc.           © 2004 Xiph. Org Foundation           Ruby © 1993 - 2003 Yukihiro Matsumoto
This site, including images and textual content, were created by and belong to me.
© 2006 - 2011 All rights reserved.

This website and tutorials have all been written in my free time (what there is of it!), and hosting can be rather costly, so any donations are very gratefully received - no matter how small - even if you can spare 50p I would be grateful!