Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> [Eventing] Button Mashing Fix
diamondandplatin...
post Apr 24 2012, 07:32 AM
Post #1


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




This is not a tutorial on how to create a button mashing system, although if you don't know how you can probably pick up the idea of how to in this tutorial.

This is a tutorial on how to fix user input in a 'Button Mashing' event.

The usual method of a implementing Button Mashing event is to create it with a variable count like this



However, there is a slight problem with doing it like that. Only the conditions have been set for variable and the key to be pressed.

What is the problem with it, you ask?
With that method, I (the player) could easily hold that button down and it would still continue to add onto the variable counter until it has reached the limit, button mashing means that I have to keep on pressing the button to achieve my goal, not hold it down.

Setting a wait frame on the branch does not change the fact that I can hold the button either.




Luckily though, there is a way to fix the button mashing issue. However it requires some scripting; do not fear, I shall step you through it.

First things first, you'll need to open up your script editor in your desired RPG Maker and create a new script above 'main' but under 'materials'.
Inside this new script that you just created, paste this code:

CODE
#===============================================================================
===
#    This Code Snippet is used to check whether or not you've already
#    pressed a specified key. It is useful if you're using an event which requires
#    the player to do some button mashing, as by default the RPG Maker will
#    allow the player to just hold that specified button to do the job.
#
#
#    It does not do the check by itself, it needs input
#    from the user to begin doing it's checks.
#
#    This means that you can run left and right and hold down any key for
#    as long as you desire unless you've evented the game not to allow for
#    that to happen.
#===============================================================================
===
module DP3_KeyPressed_Checker
  
  @isKey_Left_Pressed   = false
  @isKey_Down_Pressed   = false
  @isKey_Right_Pressed  = false
  @isKey_Up_Pressed     = false
  @isKey_A_Pressed      = false
  @isKey_B_Pressed      = false
  @isKey_C_Pressed      = false
  @isKey_X_Pressed      = false
  @isKey_Y_Pressed      = false
  @isKey_Z_Pressed      = false
  @isKey_L_Pressed      = false
  @isKey_R_Pressed      = false
  
end


If you take a look at that script, you'll notice how a lot of it says 'isKey_""_Pressed'. This will be the variable that will tell your button mashing event whether or not the player is holding the button that you want them to press, not hold.


This is what your event will look like in the end



Look difficult? Don't understand?
continue reading below.



The event is set up the same way that it normally is; however before your event process's its commands after the player presses C, it goes and checks another conditional branch which has a script call that says
!@isKey_C_Pressed

Let's go through what that means...

The @isKey_C_Pressed is simply checking the variable in the script to see whether it says 'true' or 'false'.
The ! in front of the variable tells the conditional branch to make sure that variable says false before continuing with the commands.

This means that if !@isKey_C_Pressed says 'true', then the conditional branch will not process the commands and instead process any commands in the 'else' statement. Which is nothing.



So if the variable says 'false' then the conditional branch will process the commands, which as of right now simply says to add +1 to the variable counter,
and then to change the @isKey_C_Pressed variable to say 'true'


If you've been following everything so far, this means that the conditional branch will not process these commands again because that same variable which needed to say 'false' now says 'true'.

This is what prevents the player from holding down that button during the button mashing event.
Once the player stops holding down the 'C' key, the conditional branch will process the other else statement.



Since the conditional branch is processing this else statement, that must mean that the player released the specified button, which means that we can set the @isKey_C_Pressed to say 'false' once again and allow the conditional branch to process its commands again if the player presses the specified key.





If you're not using the 'C' key, you can specify which key you are using by replacing '@isKey_C_Pressed' with
'@isKey_<Insert Key That You Are Using>_Pressed'

This post has been edited by diamondandplatinum3: Apr 24 2012, 08:04 AM


__________________________
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Renkai141
post May 21 2012, 03:13 AM
Post #2


Level 6
Group Icon

Group: Member
Posts: 78
Type: Artist
RM Skill: Intermediate




(edited > took the quote off) did it automaticly

ontopic:
I don't know if this will make u sad but. is this possible for rpg maker 2k3? too
Im currently making it in "Rpg maker 2009" just wanted to know if you can put a tutorial on that, if you can. thanks!~

This post has been edited by Renkai141: May 21 2012, 03:31 AM
Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 07:06 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker