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
514
Reaction score
488
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
514
Reaction score
488
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
514
Reaction score
488
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


Swag collecting in the new randomly generated area. Now the mini map also shows the randomly generated features... And even illustrates the whole "bubble" system" that I made to manage memory... Though that part's inadvertent. We'll just call that "the fog of war"... Yes, that's what we'll do. Nobody will be the wiser! :kaopride:
not me being not lazy for 5 seconds and drawing another char portrait (her name is hazel)
its_hazel.png
Been a while since the last time I made a song remix. Had a blast making this
One thing those jp developer still get wrong about boob physic is that... men's muscly hard pecs can jiggle too.
Definitely glad I haven't released a few of my plugins that are technically done. As I learn more, I find ways to make my code more efficient, and in one case so far, discovered an existing function that did EXACTLY what I created my own function to do.

Forum statistics

Threads
110,453
Messages
1,053,426
Members
143,541
Latest member
Neikoku
Top