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.
Register mutliple button presses
RPG Maker MV Supportthere 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.
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.
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. 👋
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:
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:
^ That's the basic idea, but you could easily elaborate it if need be with pictures or whatever to indicate the expected input. 🙂
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
@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 =)
I try to learn piece by piece to improve myself =)
Thanks guy, I'm going to see what I can do with all that and I'll get back to you.
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
@PKirkby I merged your posts together. Please don't double post in the future.
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.
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.
Oh, appreciate that, sorry.
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.
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.
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.
(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.
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.
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.
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.
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.
Original thread: https://forums.rpgmakerweb.com/threads/register-mutliple-button-presses.115270/