Auto-Forward

The Mighty Palm

Resident Palm Tree
Restaff
Joined
Jan 29, 2015
Messages
565
Reaction score
3,928
First Language
English
Primarily Uses
N/A
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,462
Reaction score
12,016
First Language
English
Primarily Uses
RMMV
Very cool! Here you go:

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.
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,462
Reaction score
12,016
First Language
English
Primarily Uses
RMMV
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?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

i watched the sonic movie it was pretty good i hope they make a sequel
tomorrow I'ma go on a cruise for the first time ever... lets hope I'll survive the experience!
Omg! 8 years in this forum :o
Ksi
Streaming the last of the RMN Valentiny event games so feel free to drop on by and watch me cry (whether that's from laughter, rage or sheer pain, who knows?)
Today I went to sleep without setting an alarm, so I could sleep more than 2 hours. I woke up after 2 hours.

Forum statistics

Threads
94,309
Messages
919,828
Members
124,060
Latest member
jloppnow
Top