Auto-Forward

I'm making a request for a very small plugin where:
When I flip Switch 1 ON for example, the game will automatically hold down the UP button on the keyboard and disable the DOWN button. When I flip Switch 1 OFF, the game stops holding UP and re-enables the DOWN key.

That's it.

No, I cannot use move routes for this, because I'm using (Altimit movement) pixel-movement and want to be able to move left and right as I go upward without the grid being involved at all. With move routes it's not only super clunky to control, the parralel process also prevents touch events from starting and I can't have that.
Very cool! Here you go:

Spoiler
Code:
/*:
* @plugindesc Auto Up (Shaz_AutoUp.js)
* @author Shaz
*
* @help This plugin does not provide plugin commands.
*
* This plugin allows you to nominate a switch, which, when ON,
* forces the player to move UP and disables the DOWN key.
*
* @param Switch ID
* @desc When ON, forces upwards movement
* @default 1
*/

(function() {
    function toNumber(str, def) {
        return isNaN(str) ? def : +(str || def);
    }

    var parameters = PluginManager.parameters('Shaz_AutoUp.js');
    var forceUpSwitch = toNumber(parameters['Switch ID'], 1);

    var _Shaz_AutoUp_Game_Player_moveByInput = Game_Player.prototype.moveByInput;
    Game_Player.prototype.moveByInput = function() {
        if (!$gameSwitches.value(forceUpSwitch)) {
            _Shaz_AutoUp_Game_Player_moveByInput.call(this);
        } else {
            if (!this.isMoving() && this.canMove()) {
                var direction = this.getInputDirection();
                $gameTemp.clearDestination();
                switch(direction) {
                    case 4:
                        this.moveDiagonally(4, 8);
                        break;
                    case 6:
                        this.moveDiagonally(6, 8);
                        break;
                    default:
                        this.moveStraight(8);
                }
            }
        }
    };

})();

Save as Shaz_AutoUp.js

When I'm feeling a little less tired, I might redo it to allow other directions.

Mmm ... not sure how it will go with a pixel movement plugin. If it doesn't work, let me know, and include a link to that one, and I'll take a peek.
@Shaz Seems to work perfectly, thanks!
Awesome! I was almost certain I'd have to rework it to be compatible with a pixel movement script. Nice surprise.


And Oops - I just realised I changed the name part way through, but forgot to go back and update the line where it's getting the parameters. This means it'll use switch 1 by default because it couldn't find the parameters, but it might not work if you wanted to use a different switch. Can you please redownload just to make sure you have the fix for that?

Original thread: https://forums.rpgmakerweb.com/threads/auto-forward.118227/