Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [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
   
Renkai141
post May 21 2012, 03:13 AM
Post #2


Level 6
Group Icon

Group: Member
Posts: 83
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
   
Jonnie19
post May 21 2012, 10:32 AM
Post #3


Are you trying to rise from your lullaby?
Group Icon

Group: Director
Posts: 1,321
Type: Developer
RM Skill: Intermediate
Rev Points: 45




Thank you for adding a tutorial for us to use and for using the correct Tags

Great work too biggrin.gif


__________________________

Finished Projects:
Slenderman's Army:


Go to the top of the page
 
+Quote Post
   
shinyjiggly
post May 21 2012, 11:27 PM
Post #4


Level 21
Group Icon

Group: Revolutionary
Posts: 431
Type: Artist
RM Skill: Beginner




QUOTE (Renkai141 @ May 21 2012, 04:13 AM) *
I don't know if this will make you sad but is this possible for RPG maker 2k3 too?
I'm currently making it in "RPG maker 2009". Just wanted to know if you can put a tutorial on that, if you can.
Thanks!~

EDIT: I've found the answer to your problems.
I apologize in advance if I am found guilty of thread hijacking by my peers.
First of all, create an event and make it a parallel process.

The first thing that you want to put in is "key input processing". This will change a variable to a particular value when a particular key sends a signal.
Unfortunately, 2003 can only track certain keys. Here is the list as seen in the help file to help you with which values are used for which key:
variable key conversion key

Number Corresponding Key(s) (When Num Lock is on)

1 Down Arrow Key, J, 2 on NumPad (When the "Number Keys" option has not been checked)
2 Left Arrow Key, H, 4 on NumPad (When the "Number Keys" option has not been checked)
3 Right Arrow Key, L, 6 on NumPad (When the "Number Keys" option has not been checked)
4 Up Arrow Key, K, 8 on NumPad (When the "Number Keys" option has not been checked)
5 Enter, Space, Z
6 Esc, X, C, V, B, N
7 Shift
10 0, 0 on NumPad (When the "Number Keys" option is checked)

11 1, 1 on NumPad (When the "Number Keys" option is checked)
12 2, 2 on NumPad (When the "Number Keys" option is checked)
13 3, 3 on NumPad (When the "Number Keys" option is checked)
14 4, 4 on NumPad (When the "Number Keys" option is checked)
15 5, 5 on NumPad (When the "Number Keys" option is checked)
16 6, 6 on NumPad (When the "Number Keys" option is checked)
17 7, 7 on NumPad (When the "Number Keys" option is checked)
18 8, 8 on NumPad (When the "Number Keys" option is checked)

19 9, 9 on NumPad (When the "Number Keys" option is checked)
20 +, + on NumPad
21 - - on NumPad
22 *, * on NumPad
23 /, / on NumPad
24 . on NumPad

Number Corresponding Key(s) (When Num Lock is off)

1 Down Arrow Key, J
2 Left Arrow Key, H
3 Right Arrow Key, L
4 Up Arrow Key, K
5 Enter, Space, Z
6 Esc, X, C, V, B, N
7 Shift
10 0
11 1
12 2
13 3
14 4
15 5
16 6
17 7
18 8
19 9
20 +

21 -
22 *
23 /

For my example, I chose to see if the 1 key was pressed by setting up a conditional branch that checked if the variable "button press" was 11.

Once the branch is set up, you need to put in a label inside of it. This will ensure that you only have to press the button down once and not twice.
After that, you can place your block of code that you wish to activate via button press. For a prototype, I added 1 to a separate variable.

Now this is the important part: Directly after your block of things to do via button press, place a Wait until key pressed. Unlike a normal wait, this one is meant to wait on your input and not a definite span of time.
Once that is out of the way, you can put in a jump to label.

in case you need a visual, here is my eventing with comments:


If you find any glaring errors in it, please do not hesitate to bring attention to them. I hope that this will be useful to you and anyone else wishing to utilize it.


__________________________
I'd be glad to help anyone with RPG Maker 2003 type questions if they need assistance.

Progress: 77%ish (back in action, baby!)
Go to the top of the page
 
+Quote Post
   
Renkai141
post May 27 2012, 01:50 PM
Post #5


Level 6
Group Icon

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




This works perfect. I'll make it of good use!
Go to the top of the page
 
+Quote Post
   
diamondandplatin...
post Jun 1 2012, 03:01 PM
Post #6


Level 5
Group Icon

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




QUOTE (shinyjiggly @ May 22 2012, 05:27 PM) *
I apologize in advance if I am found guilty of thread hijacking by my peers.

I'm ok with it smile.gif

I'm not exactly an active member, so any questions someone has for me might not be answered in a timely manner.
Thus if someone else is able to help them, I don't mind if they "Hijack" my thread.


Thanks everyone for your words. It means a lot biggrin.gif


__________________________
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: 19th June 2013 - 06:41 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker