retrofiction

Veteran
Veteran
Joined
Oct 26, 2015
Messages
32
Reaction score
16
First Language
German
Primarily Uses
RMMV
Hello!
I'm looking for a way to stop the player from moving when the OK button is being pressed. I still want the player to be able to change the direction by using the arrow keys (as well as all other keys), I just want him to stay on the spot as long as the button is being pressed.

For starters I found a solution somewhere to at least make the player stop doing anything while the OK button is being pressed (here by activating a switch upon button press):
JavaScript:
(function(alias) {
  Game_Player.prototype.getInputDirection = function() {
    if ($gameSwitches.value(10)) return 0;
    else return alias.apply(this, arguments);
  };
})(Game_Player.prototype.getInputDirection);

But it doesn't work properly at all, after a few minutes I'm getting a Maximum call stack size exceeded error message:
Unbenannt.PNG

Any ideas how to implement this?
Btw., my knowledge of JavaScript is very very basic...
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
82
Reaction score
64
First Language
English
Primarily Uses
RMMV
If you don't mind trying someone else's code, I'd give Galv's Stationary Turn plugin a look.

I used a bit of code on line 73 to use a switch so I can halt walking and turn only. So, it should work for you. You'd have to decide if you were okay with always turning in place, or else you'd have to code in the stationary turn only when holding the okay button.
 
  • Like
Reactions: TSR

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
451
Reaction score
535
First Language
French
Primarily Uses
RMMZ
Hello, if the solution above doesn't work for you, try to alias the canPass method:
Code:
var alias = Game_Player.prototype.canPass
Game_Player.prototype.canPass = function(x, y, d) {
    if (!this.isPressedOk()) {
        return alias.call(this, x, y, d);
    }
};

Game_Player.prototype.isPressedOk = function() {
    return Input.isPressed('ok') ||
           Input.isTriggered('ok') ||
           Input.isRepeated('ok');
};
 

retrofiction

Veteran
Veteran
Joined
Oct 26, 2015
Messages
32
Reaction score
16
First Language
German
Primarily Uses
RMMV
Hello, if the solution above doesn't work for you, try to alias the canPass method:
Code:
var alias = Game_Player.prototype.canPass
Game_Player.prototype.canPass = function(x, y, d) {
    if (!this.isPressedOk()) {
        return alias.call(this, x, y, d);
    }
};

Game_Player.prototype.isPressedOk = function() {
    return Input.isPressed('ok') ||
           Input.isTriggered('ok') ||
           Input.isRepeated('ok');
};
That actually works great, thank you!
What I noticed - I'm using Galvs Pseudo-Pixelmovement and when using the script above for some reason I can't change the direction to diagonal while pressing ok. Any idea how to fix that problem?
 

Latest Profile Posts

I wonder... If I develop my own game hacks, does it count as beating the game my own way?
First 12 minutes of gameplay.

bio-Synthetica's Database plugin is complete. Players will be able to find and unlock various tutorials and lore as they reach certain points. There are 5 categories of files you can unlock: Audio Clips, Data Files, Bestiary, Earth History, and Tutorials.

1653160049600.png

Thank you Dsiver for this amazing plugin! :kaothx:
My favorite kind of progress? Reverse progress! First, change some small feature of your game. Second, go back through and change 6,000 tiny things related to that minor alteration just to get your game playable again. What fun!

Forum statistics

Threads
122,009
Messages
1,145,861
Members
160,277
Latest member
Heimdal00
Top