Event scripting and varying choice menus

Kenode

Veteran
Veteran
Joined
Jun 17, 2018
Messages
68
Reaction score
26
First Language
Spanish
Primarily Uses
RMMV
Hello, first of all, this is my first time here, so please bear with me if I ask very silly things :blush:

So far, Googling around helped me with many doubts I had while learning RPG Maker MV, however I stumbled upon this one I can't seem to find anything about. I am trying to create a choice menu with options which vary depending on switches or variables.
I found this thread which has given me a great start, but I am not sure if it is explained there and I am too dumb to understand, or if I am asking for something completely different to what is explained in there.

var choices;
if($gameSwitches.value(0)) choices+=['Switch 1'];
if($gameSwitches.value(1)) choices+=['Switch 2'];
if($gameSwitches.value(2)) choices+=['Switch 3'];

$gameMessage.setChoices(choices, 0, -1);
$gameMessage.setChoiceCallback(function(responseIndex) {$gameVariables.setValue(100, (responseIndex+1));} );

Before you ask, no, I am not a programmer, so I'm sure it is something obvious that I am not seeing, or maybe improper syntax?
What I am trying is, check if a specific switch is enabled, and if it is, then add the option to a list which will be called later on the choices function, but I'm running out of ideas.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,123
First Language
English
Primarily Uses
RMMV
That method in the code is somewhat confusing, it is actually building the entire choices from scratch through script.

1.)
Here are some comments on this process:

Code:
var choices;  //Make a variable called 'choices', it has no value yet
if($gameSwitches.value(0)) choices+=['Switch 1'];  // If Game Switch #0 is ON, add "Switch 1" as a choice
if($gameSwitches.value(1)) choices+=['Switch 2']; // If Game Switch #1 is ON, add "Switch 2" as a choice
if($gameSwitches.value(2)) choices+=['Switch 3']; // If Game Switch #2 is ON, add "Switch 3" as a choice

$gameMessage.setChoices(choices, 0, -1); // Create the choice window, with the choices from earlier (between 0-3 choices
                                                                    // depending on the switches

$gameMessage.setChoiceCallback(function(responseIndex) {$gameVariables.setValue(100, (responseIndex+1));} );
// Record the choice that the player made in Game Variable #100 --> if they picked the first choice then the value of Game Variable //#100 is 1. If they picked the second choice then the value of Game Variable #100 is 2.
// This part can be made much more complicated to be flexible.

Honestly.... it's pretty confusing. If this was a big part of your game, it would not be easy --> and it has a large chance of making mistakes.

2.)
There is an alternative which is using Hime's Hidden Choice Conditions plugin. This is better, but it still involves some scripting, which can cause mistakes.

3.)
If you want to wait a few days, I am planning to write a plugin that makes this much easier, and doesn't require any scripting.

You can easily decide to <<hide,disable>> any choice directly in the choice menu.
For example:

Medium Quest<<2,3>>
--This is hidden if Switch #2 is ON, and disabled if Switch #3 is on
Here is a screenshot of how easy it would be to set up:
ChoicesBasedOnSwitch.png

So if you are interested in that, stay tuned!
 

Kenode

Veteran
Veteran
Joined
Jun 17, 2018
Messages
68
Reaction score
26
First Language
Spanish
Primarily Uses
RMMV
Hello, thanks for the answer!

Yes, that piece of code was written by me, hence why it's a mess. I even wonder if the syntax was even correct to begin with, because I get a really weird choice menu where each choice is a letter from each sentence. I wanted to avoid using plugins because I use a few Yanfly Engine Plugins, which makes me worry about inter-compatibility, plus I've read doing it through scripting would remove the limit of choices you can add in the choice box.

Would it still be possible doing it through script using your plugin by simply adding the <<x,y>> syntax to the choice string, and perhaps maybe being able to check more than a switch? (Say, maybe two or more switches to make sure all objectives are complete, or perhaps a variable to know if you've gathered X amount of an item)

If so, it would be perfect for my needs and I'd be looking forward to it! However, with all things said, I do feel, the choice menu in the base engine (what you get without plugins) could use a revision, but that's just me, or perhaps it's just my inexperience with it which is talking.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,123
First Language
English
Primarily Uses
RMMV
It's not your inexperience actually, it's a very reasonable thing that would help developers tremendously. In fact, somebody opened an MV improvement thread with this very topic, but sadly, it was never updated.

Being able to check more than one switch & variables is certainly possible. I'll be sure to tag you when it's finished and available.
 

Kenode

Veteran
Veteran
Joined
Jun 17, 2018
Messages
68
Reaction score
26
First Language
Spanish
Primarily Uses
RMMV
Cool, thanks! This thing was actually driving me nuts, because I couldn't figure it out. I'll work on other parts of the game in the mean time in that case, and come back to the choices part whenever you get a working version of your plugin.
 

Kenode

Veteran
Veteran
Joined
Jun 17, 2018
Messages
68
Reaction score
26
First Language
Spanish
Primarily Uses
RMMV
Thank you a lot, I've just read the post and it looks promising already! I will let you know in your thread how it goes later when I get to test it.
 

Latest Threads

Latest Profile Posts

Wondering how big I can make Dorothy's skill menu before the game just becomes irredeemably bad.
Studio Blue is playing the RPG Maker game Phil Alone live now! Phil may be alone, but you don't have to be, come join us in chat!

I'm in desperate need of environment sprites and tilesets for my game. If anyone is interested please DM me im willing to pay.
All badges and prizes for the Let's Make a Scene Heart Edition event SHOULD be out. If you participated and haven't received either or both, send me a PM.

Forum statistics

Threads
109,208
Messages
1,043,080
Members
141,721
Latest member
Armexploit
Top