The WhoopA Network

"B Button" Run Tutorial
Devised by WhoopA / Dan Sandstrom
Contact: whoopa@whoopanetwork.com

--- Introduction

I almost always prefer a slower walking speed in an RPG. I really don't know why. However, this can sometimes be a pain in the ass on those larger maps. So I asked myself, "Why not make it so you can hold a button to run?"

"Wait just a minute," you're probably asking. "There's no way you han have two buttons held at once and have RM2k recognize it." Wrong.

--- Method of Attack

I'm going to show you a super-spiffy use of the Enter Password command... one that lets you hold down two keys at once. It's going to knock your socks off. This script uses a Common Event: Parallel Process that constantly watches the state of "Esc", or as I like to call it, the "B Button". Ah, now you know why funny named tutorial is called the B Button Run!

If "Esc" is pressed, then released, it goes into the menu as usual. If it's pressed and HELD, the player runs until the button is released, without going into the menu.

--- Conventions

Here's the standard conventions I use in all my tutorials.

  • Numbers prefaced by "V[" or "Var[" are variables. Those without are switches.
  • A line of script in an event begins with <>.
  • All the scripts are displayed as how they should appear in the Event Commands dialog, with additional information in parenthesis.

--- Setup

The script is pure simplicity. Set up a Common Event: Parallel Process. I would recommend making it activate on switch - if you're using this script and an event is running, it can throw you into the menu at a bad time. You don't have to, but if you do (I repeat - it is recommended) check the "Appearance Conditions / Switch" box and select a switch to use. This must be ON in order for the script to take effect.

You'll also need to set aside one variable. It doesn't have to be permanently set aside - you can use it in other scripts if you like, but only as a temporary value as well.

Here we go!

--- The Script

Place this inside your common event.

<> Disable System menu

This way, we don't have that pesky menu opening at oddball times. We'll open it ourselves.

<> Enter Password: Var[0001: Temp] (Allowed keys: 6 (Esc), do not wait)
<> Fork: Var[0001: Temp] 6 (Same)

First, we check to see if Esc is down... since the entire script relies on Esc and all.

<>   Wait: 0.2sec.

If the player wants to go into the menu, they need to release Esc before the second check. The Wait command gives them time to release the button. The average human reaction time is somewhere between 15 and 25 milliseconds - if you find you can't get into the menu easily, then change the wait duration to 0.3 or 0.4 seconds, but no more. The game appears lagged if it's anything more than that.

<>   Enter Password: Var[0001: Temp] (Allowed keys: 6 (Esc), do not wait)
<>   Fork: Var[0001: Temp] 6 (Same) (Add else case)

Check the state of Esc again. This time, add the else case because we have to go into the menu if it's been released.

<>     Move event: Hero, Move speed up
<>     Move all

Speed up the hero so it seems he's running. You may also want to change the hero walk graphic here.

<>     Cycle

We next have to check the Esc button constantly so we can slow the hero back down if he's running. Best way to do that? Inside a loop.

<>       Enter Password: Var[0001: Temp] (Allowed keys: 6 (Esc), do not wait)
<>       Fork: Var[0001: Temp] 0 (Same) (Add else case)
<>         Break cycle
<>       End case

You see, we've constantly set the Enter Password to "do not wait for key" just because of this. If we told it to wait for a key and released Escape, it would stop at the Enter Password line and never continue... until we hit Esc again. Thus, we'd be stuck running forever, and never be able to get into the menu.

<>       Wait: 0.0sec.

There's that infamous lag-killer again! Take it out and see what happens... if you dare.

<>     End cycle
<>     Move event: Hero, Move speed down
<>     Move all

And slow the hero back down. I'll explain the "Move All"s in the Known Bugs section later on.

<>   Else case
<>     Call system menu
<>   End case
<> End case

That ends the script. If you're using a custom menu, you can freely replace the "Call system menu" line with whatever code you are using to get into your menu, be it a teleport, call, change switch, show picture or whatever.

--- Known bugs

Remember those two Move All commands? When I was testing the script, I found if you held down the button just long enough so that it wouldn't go into the menu but your character wouldn't run, it would actually slow down your character... permanently. The move all commands prevent that, making sure the Speed Up and Speed Down commands are executed before the script continues. Of course, if you don't go into the menu your character might be treated to a sudden speedy step... it's a small price to pay though.

The other possible bug is if you don't use the Appearance Conditions switch and press Esc in the middle of an event, you'll suddenly jump into the menu. It's only minorly annoying if you're using the default menu but can be downright disastrous if you use a custom menu. Take heed young one.

--- The final word

So, how was it? This is my second RM2k tutorial, and no doubt it's a lot easier than the first. If you want to use it, that's fine but at least have the decency to credit me for my hard work. All I ask is a mention in the credits... maybe an email saying "thanks." I get lonely, y'know.

Feel free to ask questions about the script... but only if they're intelligent. No questions along the lines of "i saw your tutorial i dont understand it help me". I may acknowledge you, but I certainly won't help.

Also feel free to tweak the script. If you see an area where you think it can be improved, do it. Possible additions include custom running graphics for your heroes, having to sneak around a facility (using a switch to keep track of whether you're running or not) and a whole lot more.

And yes, the final word is copied almost verbatim from my Party Follow tutorial. Hey, it worked the first time.

--- Legal

This document is ©2002 Dan Sandstrom.

RPG Tsukuru 2000 / RPG Maker 2000 is ©2000 ASCII / Yoji Ojima.

Ask if you wish to use this tutorial on your site, I may update it in the future. Violators will be prosecuted to the fullest extent of my foot.

The WhoopA Network - Design and content ©2001-2006 Dan Sandstrom