CarpenterScr

Veteran
Veteran
Joined
Nov 2, 2020
Messages
66
Reaction score
6
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
512
Reaction score
486
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
66
Reaction score
6
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
512
Reaction score
486
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
66
Reaction score
6
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
512
Reaction score
486
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 Posts

Latest Profile Posts

I am adamant about not having missable quests, which means having to write entirely new scenes at each plot progression that takes into account that time and events have passed since the quest could first be accepted while still having there be a quest to solve in the first place. It's worth every second.
Surprisingly useful and thought provoking
Working on animation. Trying to see if I can apply it meaningfully to my games!
ddwk.png

working on the sprite for Devali <3
My Game Development Livestream

Forum statistics

Threads
110,378
Messages
1,052,802
Members
143,420
Latest member
jaguaru
Top