MZ Making Plugin active only while control input is pressed

Hi folks,

I am using Galv's "Stationary Turn" plugin (https://galvs-scripts.com/2016/07/01/mv-stationary-turn/) in my MZ project via fossil. While the plugin works perfectly, it is only a benefit in some scenarios and a detriment in others.

I'd like to make it so that the "turn in place" effect only happens while the player is holding down the Ctrl key. The two issues I am having however are:

1.) I am not sure which part of this plugin to "wrap" in a condition without breaking it. And,
2.) I want to check for the keymapper input "control", not a specific keyboard key, so that it works with rebinding, gamepad (by binding a button to "control") and also with multiple control keys being present.

The plugin itself seems pretty basic, so hopefully this is not too hard to do.

Thanks!
I use this for testing to make direction possible (but work on it)
so it will be smoother and not fully tested:

JavaScript:
const _GamePlayer_executeMove = Game_Player.prototype.executeMove;
        Game_Player.prototype.executeMove = function(direction) {
            if (Input.isPressed("shift")) {
                if (direction === Input.dir4) {
                    this.setDirection(direction);
                }
            } else {
                _GamePlayer_executeMove.apply(this, arguments);
            }
        };

I don't know if executeMove exist in MZ, so you need to try to see if it works
or not. (change input if needed).

this is made for MV but I need to test it more, so see if it works in MZ.
Completely untested, but based on a quick look at Galv's plugin you could try one of these options:
  1. Edit line 64 of Galv's plugin:
    JavaScript:
    	if (this._turnPause > 0) {
    ...to read:
    JavaScript:
    	if (Input.isPressed("control") && this._turnPause > 0) {

  2. Add the following as a new plugin, loaded after Galv's:
    Spoiler: plugin code
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc Extends Galv_StationaryTurn - apply only while button is held.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/181094/
     * @base Galv_StationaryTurn
     * @orderAfter Galv_StationaryTurn
     * @help Free to use and/or modify for any project, no credit required.
     * Load this plugin after Galv_StationaryTurn.
     */
    ;void (function() {
    "use strict";
    
      if (!(Imported && Imported.Galv_StationaryTurn))
        throw new Error("This plugin must be loaded after Galv_StationaryTurn!");
    
      const BUTTON = "control";  // hold to enable Galv_StationaryTurn
    
      const alias = Game_Player.prototype.moveStraight;
      Game_Player.prototype.moveStraight = function() {
        const v = Galv.STURN.delay;
        if (!Input.isPressed(BUTTON))
          Galv.STURN.delay = 0;        // delay is zero if button not held
        alias.apply(this, arguments);  // process as usual
        Galv.STURN.delay = v;          // reinstate proper delay value
      };
    
    })();
Completely untested, but based on a quick look at Galv's plugin you could try one of these options:
  1. Edit line 64 of Galv's plugin:
    JavaScript:
        if (this._turnPause > 0) {
    ...to read:
    JavaScript:
        if (Input.isPressed("control") && this._turnPause > 0) {

  2. Add the following as a new plugin, loaded after Galv's:
    Spoiler: plugin code
    JavaScript:
    /*:
    * @target MV MZ
    * @plugindesc Extends Galv_StationaryTurn - apply only while button is held.
    * @author Caethyril
    * @url https://forums.rpgmakerweb.com/threads/181094/
    * @base Galv_StationaryTurn
    * @orderAfter Galv_StationaryTurn
    * @help Free to use and/or modify for any project, no credit required.
    * Load this plugin after Galv_StationaryTurn.
    */
    ;void (function() {
    "use strict";
    
      if (!(Imported && Imported.Galv_StationaryTurn))
        throw new Error("This plugin must be loaded after Galv_StationaryTurn!");
    
      const BUTTON = "control";  // hold to enable Galv_StationaryTurn
    
      const alias = Game_Player.prototype.moveStraight;
      Game_Player.prototype.moveStraight = function() {
        const v = Galv.STURN.delay;
        if (!Input.isPressed(BUTTON))
          Galv.STURN.delay = 0;        // delay is zero if button not held
        alias.apply(this, arguments);  // process as usual
        Galv.STURN.delay = v;          // reinstate proper delay value
      };
    
    })();
Amazing! This worked perfectly.

One new issue though - I am just now realizing that ctrl+S is the screenshot shortcut for rpg maker mz, and my game uses WASD for movement. Is there a way to disable that (or change the shortcut)? Maybe something in the corescript?
my game uses WASD for movement
I just have to wonder why you would do this. What's wrong with the arrow keys?

I am just now realizing that ctrl+S is the screenshot shortcut for rpg maker mz
Um… no? There's no such thing as a "screenshot shortcut" in RPGMaker as far as I know, and I even just checked in my MZ project to make sure. I'd assume you have some plugin that's adding that.
Yea, my guess would be either a plugin or another app on your system, like a snipping tool or the Steam overlay. If it works in a new project with no plugins, then it's almost certainly external.

(I think the practical reasoning behind WASD as opposed to arrow keys is ergonomics. Something about hand placement, strain of vertical vs horizontal movements, etc? Left-/right-handedness can also be important, e.g. if players want to move with keyboard but use mouse for menus.)
I think that can make sense for a game that requires simultaneous keyboard and mouse movement (unless you're left-handed), but... I don't think it makes much sense for a typical RPGMaker game where you use either keyboard or mouse but not both. Though, I have no idea how typical this particular game is.
I think that can make sense for a game that requires simultaneous keyboard and mouse movement (unless you're left-handed), but... I don't think it makes much sense for a typical RPGMaker game where you use either keyboard or mouse but not both. Though, I have no idea how typical this particular game is.

WASD is the industry standard, so for releasing a game on steam it is basically a must (as well as re-bindable controls), or else you'll get some negative reviews for it. When I had only directional keys (default), it was easily the #1 source of negative feedback. RPG Maker players are used to using arrow keys and Z/X, but most players don't like having to adjust to this control scheme. For this reason, my game uses both a WASD and arrow key layout by default. The game also has custom mouse support (which it is also hard to release to steam without), so WASD makes even more sense now. The game is a fairly standard farming/life sim in terms of controls.

Um… no? There's no such thing as a "screenshot shortcut" in RPGMaker as far as I know, and I even just checked in my MZ project to make sure. I'd assume you have some plugin that's adding that.

Yea, my guess would be either a plugin or another app on your system, like a snipping tool or the Steam overlay. If it works in a new project with no plugins, then it's almost certainly external.

(I think the practical reasoning behind WASD as opposed to arrow keys is ergonomics. Something about hand placement, strain of vertical vs horizontal movements, etc? Left-/right-handedness can also be important, e.g. if players want to move with keyboard but use mouse for menus.)

Ahh, I had figured it was a default function. I guess I'll go hunting! Hopefully it will be something I can disable (though I suppose I can just always use a different key for the stationary turn if it becomes an issue).

UPDATE: It turned out to be SRD HUD Maker Ultra. Everything is working now that the screenshot parameter is disabled.

Thanks again for all the help!
WASD is the industry standard, so for releasing a game on steam it is basically a must (as well as re-bindable controls)
Well, it's totally fine as long as you also have rebindable controls, I guess. Which RPGMaker doesn't have by default… but there are some plugins adding that (I have one in my other project; should probably actually import that into my current project too).

Original thread: https://forums.rpgmakerweb.com/threads/making-plugin-active-only-while-control-input-is-pressed.181094/