CarpenterScr

Veteran
Veteran
Joined
Nov 2, 2020
Messages
59
Reaction score
5
First Language
english
Primarily Uses
RMMV
I'd like to disable these 2 commands (taken from SRPG) if a certain switch is on.

Window_MenuCommand.prototype.addTurnEndCommand = function() {
this.addCommand(_textSrpgTurnEnd, 'turnEnd', true);
};

Window_MenuCommand.prototype.addAutoBattleCommand = function() {
this.addCommand(_textSrpgAutoBattle, 'autoBattle', true);
};

What kind of code would I need to implement it?
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
493
Reaction score
460
First Language
german
Primarily Uses
RMMZ
Code:
Window_MenuCommand.prototype.addTurnEndCommand = function() {
    if ($gameSwitches.value(XY))
        this.addCommand(_textSrpgTurnEnd, 'turnEnd', true);
};

Window_MenuCommand.prototype.addAutoBattleCommand = function() {
    if ($gameSwitches.value(XY))
        this.addCommand(_textSrpgAutoBattle, 'autoBattle', true);
};

Paste it in as a new Plugin below SRD's Plugin. Replace XY with your switch Id. Tell me if it works for you :)
 
Last edited:

CarpenterScr

Veteran
Veteran
Joined
Nov 2, 2020
Messages
59
Reaction score
5
First Language
english
Primarily Uses
RMMV
Thank you for your help.
Unfortunately I get an error message.

error.png

EDIT: I don't know if this is what you were trying to do, but I would like the two commands to be greyed out, not totally removed.
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
493
Reaction score
460
First Language
german
Primarily Uses
RMMZ
Oh, to grey them out, use this:


Code:
Window_MenuCommand.prototype.addTurnEndCommand = function() {
    const enabled = $gameSwitches.value(XY);
    this.addCommand(_textSrpgTurnEnd, 'turnEnd', enabled);
};

Window_MenuCommand.prototype.addAutoBattleCommand = function() {
    const enabled = $gameSwitches.value(XY);
    this.addCommand(_textSrpgAutoBattle, 'autoBattle', enabled);
};

Okay, the error message says, that "_textSrpgTurnEnd" is not available. I don't know how to access this variable, so I can only recommend you to add this code snippet directly into the SRPG Plugin at the bottom; If this still does not work, you may think about overriding the code parts of SRPG with my Code snippet.
 

CarpenterScr

Veteran
Veteran
Joined
Nov 2, 2020
Messages
59
Reaction score
5
First Language
english
Primarily Uses
RMMV
I'm still getting that "_textSrpgTurnEnd" is not defined (similar error).

EDIT:
this works (inserted directly in the code, not at the bottom)

Window_MenuCommand.prototype.addTurnEndCommand = function() {
const enabled = $gameSwitches.value(X);
this.addCommand(_textSrpgTurnEnd, 'turnEnd', enabled);
};


However it does the opposite... it's disabled if the switch X is OFF not ON... what should I change to make it do the opposite?
 
Last edited:

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
493
Reaction score
460
First Language
german
Primarily Uses
RMMZ
However it does the opposite... it's disabled if the switch X is OFF not ON... what should I change to make it do the opposite?
Oh, that's weird 0.o
Anyway, when you want the opposite behaviour, add a ! right before $gameSwitches.value(...), this will invert the variable "enabled".

Code:
const enabled = !$gameSwitches.value(X);
 

Latest Threads

Latest Profile Posts

Added a modern day fridge sprite to my thread. Empty, full, and rotten versions :) enjoy
I'm on YouTube moderating for an America's Funniest Home Videos livestream. They love having me there and I know spam when I see it. Tonight I had to put 3 different people in time out due to them spamming random letters. Nobody else could chat with their messages in the way!
Mist_new.png
Some WIP of Mist's newest sprites! Tutorials are awesome and very useful!

Forum statistics

Threads
109,121
Messages
1,042,276
Members
141,615
Latest member
Bamionic
Top