MZ I need help with 'Show Choices' script...

Hello. I'm trying to make a custom item menu with "Show Choices" command. I want to make it somehow to remember exactly what item was used just so player wouldn't have to scroll again if he needs to use that item again, as well as to make it possible to use an item without opening a menu again (most of my items are just common events).

After some forum browsing i found nothing, so i tried to implement it via script.
Code:
$gameMessage.setChoices(['A', 'B', 'C'], $gameVariables.value(101), -2);
$gameMessage.setChoiceBackground(2);
$gameMessage.setChoicePositionType(0);
$gameMessage.setChoiceCallback(n => {
  $gameVariables.setValue(101, n);
});
this.setWaitMode('message');
It works, but creates another problem. I'm no good with javascript. I have no idea how to script the choices themself. I assume i will have to just make a branching choice with the '101' variable, but there should be some easier way to do it probably? Also, if using this script, how can i hide certain choices? Like, can i hide a "B" option if some switch is turned off? It's a menu script after all, so this is key thing for it. Thank you for reading this!
I think I may be missing something… what exactly is there in that code that can't already be done with the Show Choices event command? I don't see see anything there that sets the initially-selected choice.

Another thing I might be missing is, why don't you use the built-in select item command? It sounds like you want to select an item, which is what that does, but if that doesn't work for you, maybe I'm misunderstanding something?

Back to the question: I think doing this by script would be very difficult when you don't know JavaScript. I'd recommend instead using the normal Show Choices event command finding some plugins – for hiding certain choices, I recommend Aloe_ConditionalChoices, but there's also HIME_HiddenChoiceConditions. I'm not sure where to find a plugin that remembers the last selected choice, but I think it could be thrown together if it doesn't exist already. The main difficulty there would be that each choice command probably wants to have a different last selected choice. But at least with this method you can still edit the choices and branches using the regular event editing UI.

If you really, really want to do this by script, you can certainly make a conditional branch on the 101 variable. You could also put the code you need to run inside the choice callback function. It really depends on what you're trying to do, I think.
Hello! Thank you for replying!
I think I may be missing something… what exactly is there in that code that can't already be done with the Show Choices event command? I don't see see anything there that sets the initially-selected choice.
Well, default Show Choices event command allows to choose only one default option. I need to make it "remember" basically the last choice player picked, which is why i'm having this script in the first place.

Another thing I might be missing is, why don't you use the built-in select item command? It sounds like you want to select an item, which is what that does, but if that doesn't work for you, maybe I'm misunderstanding something?
Default menu doesn't fit my game at all at least stylistically, so i'm trying to make a custom one. Due to the mechanics of the game, i will need at least two item categories (Consumables and Key Items), but when using default menu or some plugins that change that (like Visustella's) it doesn't look good at all! Like, they are not intended to be used with so little categories. Because of that, i figured, why not make two separate menus? Besides, i'd love to implement animations to make it prettier with Picture Choices plugin, which, obviously, requires the menu to be made as a giant "Show Choice" command.
Back to the question: I think doing this by script would be very difficult when you don't know JavaScript. I'd recommend instead using the normal Show Choices event command finding some plugins – for hiding certain choices, I recommend Aloe_ConditionalChoices, but there's also HIME_HiddenChoiceConditions.
Visustella's Message Core can hide choices i think, but thanks for other plugin recommendations!
I'm not sure where to find a plugin that remembers the last selected choice, but I think it could be thrown together if it doesn't exist already.
There was one plugin but it makes the game really laggy, so i decided not to use it unfortunately. I don't think it even was for MZ.
The main difficulty there would be that each choice command probably wants to have a different last selected choice. But at least with this method you can still edit the choices and branches using the regular event editing UI.
I would do that with choices and branches..... if i didn't had that much items in my game! Even with 10 items it becomes insufferable to event all that. I really worry that i might add some item, or remove one completely, and just because of this small change i will have to edit all those choices and branches yet again.
If you really, really want to do this by script, you can certainly make a conditional branch on the 101 variable. You could also put the code you need to run inside the choice callback function. It really depends on what you're trying to do, I think.
It's not like i want to do all this by script, rather i just don't really have a choice if i want to implement a menu like i envision it... :rsad:
Well, default Show Choices event command allows to choose only one default option. I need to make it "remember" basically the last choice player picked, which is why i'm having this script in the first place.
This is a limitation of the RPGMaker editor, yes.

Default menu doesn't fit my game at all at least stylistically
This might be almost the worst reason to use script calls here. The style of the menu can be customized without touching its functionality, and in any case your script call does nothing to change the style.

Due to the mechanics of the game, i will need at least two item categories (Consumables and Key Items), but when using default menu or some plugins that change that (like Visustella's) it doesn't look good at all! Like, they are not intended to be used with so little categories.
I don't really understand what you're saying. Two item categories is the default in RPGMaker. What exactly is the issue? If the issue is just how the menu is laid out, then what you're doing here isn't going to help at all.

Besides, i'd love to implement animations to make it prettier with Picture Choices plugin, which, obviously, requires the menu to be made as a giant "Show Choice" command.
Okay, so this is actually an okay reason to do it as a Show Choice, I guess.

Visustella's Message Core can hide choices i think, but thanks for other plugin recommendations!
I should actually apologize on that, because I missed that you were using MZ rather than MV. The two I mentioned are for MV. I don't know if they work in MZ. If VisuStella works for you, then just go with that.

I took a glance at VisuStella Message Core and it looks absolutely insane in terms of the sheer amount of content. Given that, I'm actually surprised that it doesn't have a way to set the default choice from a variable. However, I think I could make a ~5-line plugin for you that does that, just not right at this moment. That would mean you can just use a regular Show Choice and add something like "<Choice Default From Variable:101>" above it and it will work as you want it to (assuming I understand right).
I don't really understand what you're saying. Two item categories is the default in RPGMaker. What exactly is the issue? If the issue is just how the menu is laid out, then what you're doing here isn't going to help at all.
Oh, sorry for the misunderstanding! It is true, technically those are only item categories, but menus usually have armor and weapons as categories as well. In my game i don't use those, so when i remove them from menu it has this empty space.
Spoiler
Знімок екрана 2025-06-09 о 7.01.47 пп.png
This might be almost the worst reason to use script calls here. The style of the menu can be customized without touching its functionality, and in any case your script call does nothing to change the style.
Well, as i'm aware i can change menu's style only with Window.png and to some extend with Visustella's Core Engine and Main Menu Core, but i want my menu to be a list of items, sort of like in Ib or Persona 3.
Spoiler
ib-gameplay-items-2054284121.jpg
persona-3-reload-black-quartz-menu-1001102975.jpg
"Show Choice" allows me to do just that, i think? Besides, i have this script not to make changes to the menu but replace it completely, as i don't need default RPG Maker menu either with it's battle related commands. My game needs only item menu, because of that i use this script to replace it with the common event if that makes it more clear what i'm trying to implement.
Code:
Scene_Map.prototype.callMenu = function() {
$gameTemp.reserveCommonEvent(number of the common event)
}

However, I think I could make a ~5-line plugin for you that does that, just not right at this moment. That would mean you can just use a regular Show Choice and add something like "<Choice Default From Variable:101>" above it and it will work as you want it to (assuming I understand right).
Wow, that would be awesome! Yes, you do undestand me right, it is what i was looking for. Sorry for not being able to tell what i need and what is the problem clearly... Thank you!
Okay, I made two completely different mini-plugins for you to choose from. (You could even use both, if you want.)

This one replaces the menu scene with the item scene. You press escape or click the menu button, you get the item scene and only the item scene without a category selector.
JavaScript:
Scene_Map.prototype.callMenu = function() {
  SceneManager.push(Scene_Item);
};
(function(old) {
  Scene_Item.prototype.create = function() {
    old.call(this);
    this._categoryWindow.deactivate();
    this._categoryWindow.hide();
    this.activateItemWindow();
    this._itemWindow.select(0);
    this._itemWindow.setHandler("cancel",this.popScene.bind(this));
  }
})(Scene_Item.prototype.create);

And it turned out a bit longer than I expected, but this makes the game remember your last choice in each Show Choices:

JavaScript:
(function(old) {
  Game_Interpreter.prototype.setupChoices = function(params) {
    let key = [];
    if(this._depth > 0 || !this.character()) {
      key = ['common', this._commonEventId, this._index];
    } else {
      key = [$gameMap.mapId(), this.character().eventId(), this.character()._pageIndex, this._index];
    };
    $gameTemp.savedChoices = $gameTemp.savedChoices || {};
    if(key in $gameTemp.savedChoices) {
      params = params.clone();
      params[2] = $gameTemp.savedChoices[key];
    }
    old.call(this,params);
    let callback = $gameMessage._choiceCallback;
    $gameMessage.setChoiceCallback(n => (callback(n), $gameTemp.savedChoices[key] = n))
  };
})(Game_Interpreter.prototype.setupChoices);
(function(old) {
  Game_Interpreter.prototype.command117 = function(params) {
    old.call(this,params);
    if($dataCommonEvents[params[0]] && this._childInterpreter) {
      this._childInterpreter._commonEventId = params[0];
    }
    return true;
  };
})(Game_Interpreter.prototype.command117);
(function(old) {
  Game_Interpreter.prototype.setupReservedCommonEvent = function() {
    if($gameTemp.isCommonEventReserved()) {
      this._commonEventId = $gameTemp._commonEventQueue[0];
    }
    old.call(this);
  };
})(Game_Interpreter.prototype.setupReservedCommonEvent);

With that, every Show Choices in your game will have a separate memory for the last choice the player selected. I didn't check for the case of troop events – if it does something absolutely insane when you put a choice in a troop event, don't be surprised.

I did basic testing on both of them in MZ and they seem to work. I can't be certain that there are unexpected side-effects that I missed. Let me know if you run into any issues.

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-with-show-choices-script.178221/