PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
19
First Language
english
Primarily Uses
RMMV
Hi everyone, is there a way to register multiple buttons being pressed. In this case, I have an event underneath the character that allows them to jump, however I'd like to be able to move up and down and still have the jump event register as im moving up or down. Thanks in advance.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,693
Reaction score
1,805
First Language
Dutch
Primarily Uses
RMMV
there is a way using a script call:

Input.isPressed("KEYCODE") && Input.isPressed("KEYCODE")
or
Input.isTriggered("KEYCODE") && Input.isTriggered("KEYCODE")

just use && if 3 buttons need to be pressed.
There was a nice plugin for it as well, but I dont know its name at this point though.

KEYCODE = the number or if its allowed (when so in the help file) you can use A, B, Z etc
else use the keycode found here.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,986
Reaction score
2,304
First Language
EN
Primarily Uses
RMMZ
Note that isTriggered is true only for one frame when the button changes from "not-pressed" to "pressed"...I wouldn't recommend using two isTriggered checks simultaneously unless you want your players to be really good at timing their button presses. :kaoback:

Also, only keys defined in the game's keyMapper will register via isPressed/isTriggered, and then only by the names they're assigned. Excerpt from rpg_core.js for reference:
Code:
Input.keyMapper = {
    9: 'tab',       // tab
    13: 'ok',       // enter
    16: 'shift',    // shift
    17: 'control',  // control
    18: 'control',  // alt
    27: 'escape',   // escape
    32: 'ok',       // space
    33: 'pageup',   // pageup
    34: 'pagedown', // pagedown
    37: 'left',     // left arrow
    38: 'up',       // up arrow
    39: 'right',    // right arrow
    40: 'down',     // down arrow
    45: 'escape',   // insert
    81: 'pageup',   // Q
    87: 'pagedown', // W
    88: 'escape',   // X
    90: 'ok',       // Z
    96: 'escape',   // numpad 0
    98: 'down',     // numpad 2
    100: 'left',    // numpad 4
    102: 'right',   // numpad 6
    104: 'up',      // numpad 8
    120: 'debug'    // F9
};

My take on this idea is "hold the OK button and press a direction to jump that way". You can achieve that with a simple Action Button event using a Loop and a few Conditional Branch and Break Loop commands, no scripting required. Example:
Code:
◆Loop
  ◆If:Button [OK] is pressed down
    ◆Comment:OK, jump in which direction?
    ◆If:Button [Up] is pressed down
      ◆Comment:Up!
      ◆Set Movement Route:Player (Wait)
      :                  :◇Jump:+0, -2
      ◆Break Loop
      ◆
    :Else
      ◆If:Button [Down] is pressed down
        ◆Comment:Down!
        ◆Set Movement Route:Player (Wait)
        :                  :◇Jump:+0, +2
        ◆Break Loop
        ◆
      :End
      ◆
    :End
    ◆
  :Else
    ◆Comment:OK button released: end event.
    ◆Break Loop
    ◆
  :End
  ◆Comment:Check again next frame for input.
  ◆Wait:1 frame
  ◆
:Repeat Above
^ That's the basic idea, but you could easily elaborate it if need be with pictures or whatever to indicate the expected input. :)
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,693
Reaction score
1,805
First Language
Dutch
Primarily Uses
RMMV
@caethyril I had no idea about the triggered and pressed part, but I keep that in mind :)
I try to learn piece by piece to improve myself =)
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
19
First Language
english
Primarily Uses
RMMV
Thanks guy, I'm going to see what I can do with all that and I'll get back to you.

there is a way using a script call:

Input.isPressed("KEYCODE") && Input.isPressed("KEYCODE")
or
Input.isTriggered("KEYCODE") && Input.isTriggered("KEYCODE")

just use && if 3 buttons need to be pressed.
There was a nice plugin for it as well, but I dont know its name at this point though.

KEYCODE = the number or if its allowed (when so in the help file) you can use A, B, Z etc
else use the keycode found here.
Ok so I'll have to put several of those conditional statements for each possible button combo? And then how do I put implement this to do my "Set Movement Route" I know how to call script, but I'm not sure how to do the && in RPGmaker with conditional Branches. Thanks
 
Last edited by a moderator:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,693
Reaction score
1,805
First Language
Dutch
Primarily Uses
RMMV
if in condition branch, 4th tab and than script.

than do what it should do (no else handler) unless its needed ofcourse.
but to extend the buttons for it, you need a plugin to use A, B, C, D etc,

which can be found here.
if you still stuck, someone else might explain how to do certain things.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
19
First Language
english
Primarily Uses
RMMV
While all of these kind of do work, I still have the same issue. I can only jump while standing still, but while I'm moving up or down I cannot jump.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
19
First Language
english
Primarily Uses
RMMV
there is always SmartJump plugin, if the button pressed is to hard for you :)
Yeah, I am using that, but there are so many variables. I'm trying to have a scene with constant motion to the right, like driving a vehicle for example. I've decided to try scrolling the map, and keeping the player standing still. My problem is that the smart jump always jumps forward, but I only want to be able to move up and down and jump straight up. I've tried your methods, and have them working, but it still seems i cant jump while also moving up and down. Thanks again.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,693
Reaction score
1,805
First Language
Dutch
Primarily Uses
RMMV
if you follow what caethyril said above, you should making it up or down, but if you just want to jump on the same spot
(without going up or down) you need to jump with x +0, y +0 so it just jump on the same spot.
else you can jump left, right, up, down.

JUMP ON SPOT = x +0, y +0
Jump UP 1 tile = x +0, y -1
Jump RIGHT 1 tile = x +1, y +0
Jump DOWN 1 tile = x +0, y +1
Jump LEFT 1 tile = x -1, y +0

change 1 if you want to jump further.
but its plain easy. but if you want to jump, make a switch JUMP ON,
and in the common event the condition branch in parallel process, so you can jump whenever you like
in which direct the you press the button.
 

PKirkby

Veteran
Veteran
Joined
Oct 26, 2019
Messages
157
Reaction score
19
First Language
english
Primarily Uses
RMMV
if you follow what caethyril said above, you should making it up or down, but if you just want to jump on the same spot
(without going up or down) you need to jump with x +0, y +0 so it just jump on the same spot.
else you can jump left, right, up, down.

JUMP ON SPOT = x +0, y +0
Jump UP 1 tile = x +0, y -1
Jump RIGHT 1 tile = x +1, y +0
Jump DOWN 1 tile = x +0, y +1
Jump LEFT 1 tile = x -1, y +0

change 1 if you want to jump further.
but its plain easy. but if you want to jump, make a switch JUMP ON,
and in the common event the condition branch in parallel process, so you can jump whenever you like
in which direct the you press the button.
Yeah, I've figured all that out, I've even figured out how to edit some files for a higher jump, however I still can't jump while moving up and down, I can only jump while standing still. Seems RPGmaker doesnt like to allow both actions at once.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,693
Reaction score
1,805
First Language
Dutch
Primarily Uses
RMMV
it does allow both options.

Make a common Event: name it JUMP, Action to PARALLEL, SWITCH to JUMP ON (make this switch)

in the event:
If button pressed is UP
Jump player x +0, y -1
end

If button pressed is DOWN
Jump player x +0, y +1
END

there are other methods as well, but if its parallel, you can jump while walking, do the same with right and left
if need too. its thats simple, nothing more, nothing less.
 

daemon

Elemental One
Member
Joined
Feb 23, 2016
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello everybody, its' been a while since no post on this topic. I hope evreybody is keeping well and safe. Is it still to open to post a new topic idea? I want to register multiple key presses on a keyboard I have so far seen it is possible to do 3 things inside rpg game maker MV, a button press, a long button press and a input is triggered.


From my understanding it seems that button press is simply pressing button down, it is not limited to being held down for a few seconds, whilst the long key press is needed to be held down for a few seconds.


Well I wanted to combine a long key press follwoed with a simple key press, my aim is to emulate a computer learning tool which can use someone about keyboard shortcuts such as cltr + c and many others.


I have tried using the code to do so, whereas i have replaced "KEYCODE with both the button name such as A,B,S,enter e.t.c and also tried using the keycode number from the link given link http://keycode.info/ and also installed the ZE keymapper plugin from https://mvplugins.com/plugin/Zalerinian/ZE - Key Mapper to allow myself to use more keys on the keybaord.


This is what I have found


Input.isPressed("KEYCODE") && Input.isPressed("KEYCODE")


or


Input.isTriggered("KEYCODE") && Input.isTriggered("KEYCODE")


But what i am confused about it I tried to apply this to a simple event so created a quick character and made them say something like well done the cltr and c key has been pressed or oops try again. I tried to integrate this all into an if function to try to get something like this


if (Input.isLongPressed("ctrl") && Input.isPressed("c")) {


$gameMessage.add("You have pressed cltr and c, now you can copy stuff");


} else {


$gameMessage.add("Oops try again");


I am going wrong somewhere so basically i just want to say


if the two buttons are pressed, the cltr key has to be long pressed and the c key pressed


then the other npc says well done


else they will ask you to try again.


When I use the Input.isLongPressed command how do I also specifiy the time they have to hold it for too. If someone could say that would be good.


I also then tried to define the keymapper by trying to put these two lines above the others, just in case that was lacking.


Input.keyMapper[17] = 'ctrl'


Input.keyMapper[67] = 'c'


Can anyone please help and say where I am going wrong, I am only a well beginner in this.
 

Latest Threads

Latest Posts

Latest Profile Posts

If the world treats you like an enemy... Then the world must be your enemy...
Last monday Hawkzombie played ATV.

Here are the videos:


Yes, I'm alive. No the semester didn't kill me. Though there are days I feel like I am dead.
In the review stages for Pixacrea to be put up on Steam :) Coming Soon page... hopefully coming soon ;)
since all my maps are hand drawn... I admit, I super envy those who can make the tileset's work. I'm garbage at mapping, but slightly less bad at just drawing my own areas. plus it's easier to draw my own sprites than edit others to look like my characters.

Forum statistics

Threads
117,289
Messages
1,106,174
Members
153,477
Latest member
GingaAle
Top