Status
Not open for further replies.

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
540
Reaction score
326
First Language
Portuguese(BR)
Primarily Uses
RMMV
I'm trying to add gamepad support to a game of mine, but due to how limited the amount of buttons on it is, and the fact that I added extra commands to the game(such as fire, drop things,etc) I need a system capable of detecting two buttons pressed at once( and/or one being hold then the other being pressed).

I tried creating an alias for the Scene_Map.updateScene that would check when two buttons are pressed at once, but doesn't seem to work(It detects individual button presses, but not multiple at once). Any ideas?

My code so far:

Code:
var keyconfig_alias = Scene_Map.prototype.updateScene;
   Scene_Map.prototype.updateScene = function() {
     keyconfig_alias.call(this);

       if (!SceneManager.isSceneChanging() && ($gameMap._mapId==1 || $gameMap._mapId==5)) {

       if (Input.isTriggered('weapon')||(Input.isTriggered('fire') && Input.isTriggered('ok'))) {
        ///use weapon

        if(weapondelay===0 && chatopen===false){

            $gameTemp.reserveCommonEvent(2);
        }


    }
     if ((Input.isTriggered('shield') || (Input.isTriggered('fire') && Input.isTriggered('cancel'))) && chatopen===false) {
         ///equip shield
        $gameTemp.reserveCommonEvent(3);
    }
    else if((Input.isTriggered('potion') || (Input.isTriggered('fire') && Input.isTriggered('menu'))) && chatopen===false){
        ///consume potion
        $gameTemp.reserveCommonEvent(7);
    }
    else if((Input.isTriggered('dropweapon') || (Input.isTriggered('drop') && Input.isTriggered('ok'))) && chatopen===false){
        ///drop weapon
        $gameTemp.reserveCommonEvent(8);
    }
    else if((Input.isTriggered('droppotion') || (Input.isTriggered('drop') && Input.isTriggered('cancel'))) && chatopen===false){
        ///drop heal
        $gameTemp.reserveCommonEvent(10);
    }
    else if((Input.isTriggered('dropshield') || (Input.isTriggered('drop') && Input.isTriggered('menu'))) && chatopen===false){
        ///drop shield
        $gameTemp.reserveCommonEvent(9);
    }
          
       }
   };
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,509
Reaction score
2,635
First Language
EN
Primarily Uses
RMMZ
Maybe try Input.isPressed() instead of isTriggered()? I think isTriggered is a single-frame thing, fired when the button is initially pressed down. For comparison, the Conditional Branch check (event command) uses isPressed. Relevant code can be found in rpg_core.js, under Input. :)
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
540
Reaction score
326
First Language
Portuguese(BR)
Primarily Uses
RMMV
Maybe try Input.isPressed() instead of isTriggered()? I think isTriggered is a single-frame thing, fired when the button is initially pressed down. For comparison, the Conditional Branch check (event command) uses isPressed. Relevant code can be found in rpg_core.js, under Input. :)
That worked perfectly, thank you!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,580
Reaction score
12,123
First Language
English
Primarily Uses
RMVXA
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

I'm working with Excel today, and I just hate VBA so much. It's like the designers said "How can we make a programming language that works as obtusely and inefficiently as possible?"
Beep-Beep-Motha-facka.gif

Just finished and uploaded the delivery truck base/sprite sheet. I've been steadily replacing the default assets with early modern alternatives. The air-ship for a biplane, horse-drawn wagon for a delivery truck, and next a sailboat for a steam-powered passenger liner (think of the SS Olympic and RMS Titanic).
I caught a shiny magikarp on pokemonGO today AND finally saw Detective Pikachu and it was so cute and I'm still so hype AHHHHH!!!
one of the coolest things I've learned from the forums is the ability to give yourself a hitbox. I have a move you can do on the fields. shoulder tackle. thanks to the forums, that tackle triggers self A switches on some events. NPC's and the environment now react to the tackle. awesome.
I really liked how this one turned out! :kaopride:
WYqMPf6.png

Character (Yes, this is a character): Nibiru the Primal Being from Yugioh.

Forum statistics

Threads
121,947
Messages
1,145,370
Members
160,220
Latest member
Trex1930
Top