Temporarly disable key inputs

Hi,
In my current project I use map abilities, so basically when the player presses a specific key, the ability will then play. However I want to be able to temporarly disable the key inputs for some specifc events. For instance I have this event on the map that will move the player to an other location (not transfer but pathfind the player). The problem is that during the pathfinding moment, if the player presses a key, it will cancel. I have a few other places where this might happen and I want to know if it's possible to just temporarly stop the key input.


Is there maybe a simple script or something that would allow that ?
Events with trigger Autorun are normaly used for Cutscenes where the Player cant move with directional Button Input.
Maybe you can utilise this behavior for your Mechanic.
You can create a small Plugin like this

Code:
Input.isEnabled = true;

var alias1 = Input.update;
var alias2 = Input.isPressed;
var alias3 = Input.isTriggered;
var alias4 = Input.isRepeated;
var alias5 = Input.isLongPressed;

Input.update = function() {
    if (this.isEnabled) alias1.call(this);
}

Input.isPressed = function(arg) {
    return this.isEnabled && alias2.call(this, arg);
}

Input.isTriggered = function(arg) {
    return this.isEnabled && alias3.call(this, arg);
}

Input.isRepeated = function(arg) {
    return this.isEnabled && alias4.call(this, arg);
}

Input.isLongPressed = function(arg) {
    return this.isEnabled && alias5.call(this, arg);
}

To enable/disable Input, use a Script Call
Input.isEnabled = true;
or
Input.isEnabled = false;

Tell me if that works for you 🙂
Events with trigger Autorun are normaly used for Cutscenes where the Player cant move with directional Button Input.
Maybe you can utilise this behavior for your Mechanic.

Well that's the first thing I tried, but apparently autorun only blocks the basic movements, not the other inputs.
You can create a small Plugin like this

Code:
Input.isEnabled = true;

var alias1 = Input.update;
var alias2 = Input.isPressed;
var alias3 = Input.isTriggered;
var alias4 = Input.isRepeated;
var alias5 = Input.isLongPressed;

Input.update = function() {
    if (this.isEnabled) alias1.call(this);
}

Input.isPressed = function(arg) {
    return this.isEnabled && alias2.call(this, arg);
}

Input.isTriggered = function(arg) {
    return this.isEnabled && alias3.call(this, arg);
}

Input.isRepeated = function(arg) {
    return this.isEnabled && alias4.call(this, arg);
}

Input.isLongPressed = function(arg) {
    return this.isEnabled && alias5.call(this, arg);
}

To enable/disable Input, use a Script Call
Input.isEnabled = true;
or
Input.isEnabled = false;

Tell me if that works for you 🙂

That works 100% perfectly ! That's exactly what I needed, thanks a lot !
Well that's the first thing I tried, but apparently autorun only blocks the basic movements, not the other inputs.
Well, actually it does. Unless you have Plugins that change this behaviour. What buttons are still working?

EDIT:
Well nevermind, if the script works then we don't have to know why the Autorun doesnt work as intended 😀
Well I was using some simple script commands like : If Script : Input.isTriggered('&') ...

Thanks so much for the script, it's really gonna make my work so much easier !
You can create a small Plugin like this

Code:
Input.isEnabled = true;

var alias1 = Input.update;
var alias2 = Input.isPressed;
var alias3 = Input.isTriggered;
var alias4 = Input.isRepeated;
var alias5 = Input.isLongPressed;

Input.update = function() {
    if (this.isEnabled) alias1.call(this);
}

Input.isPressed = function(arg) {
    return this.isEnabled && alias2.call(this, arg);
}

Input.isTriggered = function(arg) {
    return this.isEnabled && alias3.call(this, arg);
}

Input.isRepeated = function(arg) {
    return this.isEnabled && alias4.call(this, arg);
}

Input.isLongPressed = function(arg) {
    return this.isEnabled && alias5.call(this, arg);
}

To enable/disable Input, use a Script Call
Input.isEnabled = true;
or
Input.isEnabled = false;

Tell me if that works for you 🙂
Is there a way to cancel any input already pressed before the Input.isEnabled = false script happens? In my case, if a region has an event and I start it with
Input.isEnabled = false;
then close it with
Input.isEnabled = true;
if the player kept pressing the directional arrow since they triggered the event it still moves after the event happens (as if in cache there were still memory of that input).

Is there a script to be called to cancel any input already pressed but still in the cache?

EDIT:

found this in objects.js how should I call it?

Code:
/**
* Clears all the input data.
*
* @ static
* @method clear
*/
Input.clear = function() {
this._currentState = {};
this._previousState = {};
this._gamepadStates = [];
this._latestButton = null;
this._pressedTime = 0;
this._dir4 = 0;
this._dir8 = 0;
this._preferredAxis = '';
this._date = 0;
found this in objects.js how should I call it?
Code:
Input.clear()
likeAerosys said, "to the point".

if it has a function like:

input.clear = function() {
and code here
}

than it will be input.clear() to call it, if the function is called
powerLevel = function {
code
}

than the scriptcall is powerLevel() to call it.

keep in mind this doesn't allways work, it really depends on the function
and plugin if they are open to use them, if they arent in the documentation.
Works perfectly, thank you
You can create a small Plugin like this

Code:
Input.isEnabled = true;

var alias1 = Input.update;
var alias2 = Input.isPressed;
var alias3 = Input.isTriggered;
var alias4 = Input.isRepeated;
var alias5 = Input.isLongPressed;

Input.update = function() {
    if (this.isEnabled) alias1.call(this);
}

Input.isPressed = function(arg) {
    return this.isEnabled && alias2.call(this, arg);
}

Input.isTriggered = function(arg) {
    return this.isEnabled && alias3.call(this, arg);
}

Input.isRepeated = function(arg) {
    return this.isEnabled && alias4.call(this, arg);
}

Input.isLongPressed = function(arg) {
    return this.isEnabled && alias5.call(this, arg);
}

To enable/disable Input, use a Script Call
Input.isEnabled = true;
or
Input.isEnabled = false;

Tell me if that works for you 🙂
Good day! Is there any way to disable a mouse input in a similar manner? Seems like it's the only input that is unaffected by the script call. Thank you for your time in advance!

EDIT: Good day again 😍 It seems I was able to make it work on my own. I apologize for taking your time. If someone will find it curious, I basically copied the same structure while referencing rpg_core.js and just added it below.

JavaScript:
TouchInput.isEnabled = true;


var alias6 = TouchInput.update;
var alias7 = TouchInput.isPressed;
var alias8 = TouchInput.isTriggered;
var alias9 = TouchInput.isRepeated;
var alias10 = TouchInput.isLongPressed;
var alias11 = TouchInput.isCancelled;
var alias12 = TouchInput.isMoved;
var alias13 = TouchInput.isReleased;


TouchInput.update = function() {
    if (this.isEnabled) alias6.call(this);
}


TouchInput.isPressed = function(arg) {
    return this.isEnabled && alias7.call(this, arg);
}


TouchInput.isTriggered = function(arg) {
    return this.isEnabled && alias8.call(this, arg);
}


TouchInput.isRepeated = function(arg) {
    return this.isEnabled && alias9.call(this, arg);
}


TouchInput.isLongPressed = function(arg) {
    return this.isEnabled && alias10.call(this, arg);
}


TouchInput.isCancelled = function(arg) {
    return this.isEnabled && alias11.call(this, arg);
}


TouchInput.isMoved = function(arg) {
    return this.isEnabled && alias12.call(this, arg);
}


TouchInput.isReleased = function(arg) {
    return this.isEnabled && alias13.call(this, arg);
}

I'm not well-versed in these things, but it seems to work. Works the same way by using a script call TouchInput.isEnabled = true; or TouchInput.isEnabled = false;

Original thread: https://forums.rpgmakerweb.com/threads/temporarly-disable-key-inputs.124838/