Override Player Inputs

Hi all,

I'm looking for how I would go about hijacking the player's input to prevent the inputs from actually moving the player. I'm thinking it would look something like this:
Code:
if (overridePlayerMovement)
{
  // Do something with the movement
}
else
{
  base.PlayerMovement();
}

Does anyone have any experience with something like this?
Hi!
I think the right function is that one from RPG objects:
JavaScript:
Game_Player.prototype.moveByInput = function() {
    if (!this.isMoving() && this.canMove()) {
        var direction = this.getInputDirection();
        if (direction > 0) {
            $gameTemp.clearDestination();
        } else if ($gameTemp.isDestinationValid()){
            var x = $gameTemp.destinationX();
            var y = $gameTemp.destinationY();
            direction = this.findDirectionTo(x, y);
        }
        if (direction > 0) {
            this.executeMove(direction);
        }
    }
};
You will have to alias that then you can put your if condition like:
JavaScript:
const alias = Game_Player.prototype.moveByInput;
Game_Player.prototype.moveByInput = function() {
if(your condition){
    // do your code
}else{
    alias.call(this);
}
};

EDIT:
This function is called on game player update:
JavaScript:
Game_Player.prototype.update = function(sceneActive) {
    var lastScrolledX = this.scrolledX();
    var lastScrolledY = this.scrolledY();
    var wasMoving = this.isMoving();
    this.updateDashing();
    if (sceneActive) {
        >>>>>>>> this.moveByInput(); <<<<<<<
    }
    Game_Character.prototype.update.call(this);
    this.updateScroll(lastScrolledX, lastScrolledY);
    this.updateVehicle();
    if (!this.isMoving()) {
        this.updateNonmoving(wasMoving);
    }
    this._followers.update();
};
If you just want to override the move direction then you can alias getInputDirection, e.g.
JavaScript:
(function(alias) {
  Game_Player.prototype.getInputDirection = function() {
    if ($gameSwitches.value(1)) return 0;
    else return alias.apply(this, arguments);
  };
})(Game_Player.prototype.getInputDirection);
I.e. "if game switch #1 is on then there is no input direction, otherwise get input as normal".
Thank you both! Did the trick exactly!

Original thread: https://forums.rpgmakerweb.com/threads/override-player-inputs.123680/