Disable custom menu option based on switch value

Jimminybob

Villager
Member
Joined
Apr 17, 2017
Messages
24
Reaction score
7
First Language
English
Primarily Uses
RMMV
Hi,

I've created a custom menu for my game and one of the options on there is to view a map of the current location. However the map itself isn't available, story wise, until the player examines a certain location and finds it. Based on that I'd like to have the menu option disabled until the located is examined and a switch turned on.

I've tried to do this in some experiments but I couldn't get it right, so I was hoping someone could tell me how to achieve this.

Thanks
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,082
First Language
English
Primarily Uses
RMMV
I assume you're using some type of Window_Command ? If so, take inspiration from the default menu, specifically this function:
Code:
Window_MenuCommand.prototype.addMainCommands = function() {
   var enabled = this.areMainCommandsEnabled();
   if (this.needsCommand('item')) {
      this.addCommand(TextManager.item, 'item', enabled);
   }
   if (this.needsCommand('skill')) {
      this.addCommand(TextManager.skill, 'skill', enabled);
   }
   if (this.needsCommand('equip')) {
      this.addCommand(TextManager.equip, 'equip', enabled);
   }
   if (this.needsCommand('status')) {
      this.addCommand(TextManager.status, 'status', enabled);
   }
};

Something like this:
Code:
//Switch #1 is whether the map command is added to the command window
//Switch #2 is whether the map command is enabled or not
MyWindow.prototype.addMapCommand = function() {
   if ($gameSwitches.value(1)) {
      this.addCommand("View the Map", 'map', $gameSwitches.value(2));
   }
};
 

Jimminybob

Villager
Member
Joined
Apr 17, 2017
Messages
24
Reaction score
7
First Language
English
Primarily Uses
RMMV
Thanks very much, that worked perfectly. I had tried to get the switch value in a different way but that didn't work.

Thanks again.
 

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

Latest Threads

Latest Profile Posts

Kes
Came up with a good name for something. Checked on internet - device trademark filed in India 2017. Back to the drawing board.
I want to see the Features of the new RPG Maker.. NOW!!
Can't wait for it!
KDS
Check out some gameplay of a game iam working on :)
Me : "Wearing glasses is annoying."
*put out glasses*
Also me : "Keep mistaking 0, 6 and 8."
oh god, a new version of RPG Maker is coming soon already....

Forum statistics

Threads
98,126
Messages
949,500
Members
129,410
Latest member
Charles_Chandra
Top