Does anyone know plugin or workaround for messages inside the conditional brances before the choice list? The message disappears in this case, which is annoying, because the only way to make it stay is to leave it as is before the choice list. I searched, and it seems there are no plugins or solutions to that, which I hardly believe. If anyone knows how to solve this, please let me know.
MZ Message window inside the conditional branch disappears before the choice list
Javascript/Plugin SupportLate Edit: Good catch by Solar_Flare, see answers below.
Depending on how complex your text is, one work around could be to put the text difference in one or multiple variables/unused actor names, and reference that in your "Message Text" command (you cannot put special text commands in variables, so you would have to splice around those if your text contains some).
You could also replace the "Message Text" and "Show Choices" with script commands (see MV/MZ script call list).
You can prevent the interpreter from stopping after the first Message Text by only putting the
If you do want a plugin for this specific case, you could maybe try something like this:
Depending on how complex your text is, one work around could be to put the text difference in one or multiple variables/unused actor names, and reference that in your "Message Text" command (you cannot put special text commands in variables, so you would have to splice around those if your text contains some).
You could also replace the "Message Text" and "Show Choices" with script commands (see MV/MZ script call list).
You can prevent the interpreter from stopping after the first Message Text by only putting the
this.setWaitMode('message') line in the last command:
Code:
[...]
♦If : ChoiceCount = 2
♦Script : $gameMessage.setFaceImage("UI/Inspect", 0);
: : $gameMessage.setBackground(0);
: : $gameMessage.setPositionType(2);
: : $gameMessage.setSpeakerName("");
: : $gameMessage.add("<Position: 210, 445, 450, 110>\\TextDelay[3]\\LSPI[100]<i>There is a drink ins...");
♦
: End
♦Script : let choices = [
: : "<Hide Switch: 615><Choice Width: 350><Choice Common Event: 718>\\I[567] Bottled ...",
: : "..."
: : ];
: : $gameMessage.setChoices(choices, 0, -1);
: : $gameMessage.setChoiceBackground(0);
: : $gameMessage.setChoicePositionType(2);
: : $gameMessage.setChoiceCallback(n => {
: : $gameVariables.setValue(1509, n);
: : });
: :
: : this.setWaitMode("message");
♦If : ChoiceSelection#1509 = 0
[...]
If you do want a plugin for this specific case, you could maybe try something like this:
JavaScript:
/*:
* @plugindesc
* "Message Text" will search past the end of conditional branches.
*/
Game_Interpreter.prototype.command101 = (alias => function(params) {
let result = alias.call(params);
if (result && [101, 401].contains(this.currentCommand().code) && !this.command412) {
while (this._list[this._index + 1] && [0, 412].contains(this.nextEventCode())) {
this._index++;
}
switch (this.nextEventCode()) {
case 102: // Show Choices
this._index++;
this.setupChoices(this.currentCommand().parameters);
break;
case 103: // Input Number
this._index++;
this.setupNumInput(this.currentCommand().parameters);
break;
case 104: // Select Item
this._index++;
this.setupItemChoice(this.currentCommand().parameters);
break;
}
}
return result;
})(Game_Interpreter.prototype.command101);
…what are you talking about? Why would you be unable to put special text commands in variables?
EDIT: I gave it a try and figured out why you'd think that. It's because of the backslash substitution. You can still use them, but there's a bit of extra syntax:
Code:
◆Control Variables:#0001 = "This is a test of \x1bN[1].\x1b..\x1b.."
◆Text:None, None, Window, Bottom
: :\V[1]
All those
1b are there to make the text codes work.EDIT2: That plugin looks great, but it won't directly solve the original poster's problem, since they have multiple If statements to skip over. Perhaps it could work out with a bit of enhancement to the plugin if the statements are rephrased as an if-else chain though? On the other hand, I have a feeling that their specific problem is better solved with a plural substitution plugin…
I would suggest solving it using the "Label" and "Jump To Label" features along with a plugin. Basically, add this plugin to your project (or at the end of existing plugin) and start using labels. Place a "Jump To Label" command right after the text, and put a "Label" command just before the choice you want to jump to.
The plugin will check whether there's a "Jump To Label" after the text, verify that a choice command follows that label, and then merge the commands automatically.
The plugin will check whether there's a "Jump To Label" after the text, verify that a choice command follows that label, and then merge the commands automatically.
JavaScript:
(function() {
Game_Interpreter.prototype.command101 = function(params) {
if ($gameMessage.isBusy()) {
return false;
}
$gameMessage.setFaceImage(params[0], params[1]);
$gameMessage.setBackground(params[2]);
$gameMessage.setPositionType(params[3]);
$gameMessage.setSpeakerName(params[4]);
while (this.nextEventCode() === 401) {
this._index++;
$gameMessage.add(this.currentCommand().parameters[0]);
}
switch (this.nextEventCode()) {
case 102:
this._index++;
this.setupChoices(this.currentCommand().parameters);
break;
case 103:
this._index++;
this.setupNumInput(this.currentCommand().parameters);
break;
case 104:
this._index++;
this.setupItemChoice(this.currentCommand().parameters);
break;
case 119:
this.setupInputFromLabel();
break;
}
this.setWaitMode("message");
return true;
};
Game_Interpreter.prototype.setupInputFromLabel = function() {
const labelName = this._list[this._index + 1].parameters[0];
for (let i = 0; i < this._list.length; i++) {
const cmd = this._list[i];
if (cmd.code === 118 && cmd.parameters[0] === labelName) {
const nextCmd = this._list[i + 1];
if (nextCmd && [102, 103, 104].includes(nextCmd.code)) {
this._index++;
this.jumpTo(i + 1);
switch (this.currentCommand().code) {
case 102:
this.setupChoices(this.currentCommand().parameters);
break;
case 103:
this.setupNumInput(this.currentCommand().parameters);
break;
case 104:
this.setupItemChoice(this.currentCommand().parameters);
break;
}
}
break;
}
}
};
})();
Late reply, but I just tried the plugin, and based on position in plugin list it either doesn't work, or breaks the choice function entirely (by not reacting to the commands that should happen when you pick the choice option). It also displays me the message that this plugin may not support RPG Maker MZ, so it seems like there's some issues with this.
I don't own MZ, but the message can be safely ignored if it does work.
it mostly require
@target MZ on top to make the message disappear.if you did follow the above with the jump to label it may work, but I can't test it unfortunately.
Not sure which code you're referring to. My code is definitely working, but the issue might be a conflict between plugins. From your screenshot, it's clear you're using some choice plugins, and they can cause problems if they override the text command as well.
I’ve added an alias to the text command this should help resolve the conflict. Make sure this code is lower than any other choice/message plugins. If it still doesn't work, without knowing exactly which plugins you're using or what are doing I can't help.
JavaScript:
(function() {
const _Game_Interpreter_command101 = Game_Interpreter.prototype.command101;
Game_Interpreter.prototype.command101 = function(params) {
const result = _Game_Interpreter_command101.call(this, params);
if (result && this.nextEventCode() === 119) {
this.setupInputFromLabel();
}
return result;
};
Game_Interpreter.prototype.setupInputFromLabel = function() {
const labelName = this._list[this._index + 1].parameters[0];
for (let i = 0; i < this._list.length; i++) {
const cmd = this._list[i];
if (cmd.code === 118 && cmd.parameters[0] === labelName) {
const nextCmd = this._list[i + 1];
if (nextCmd && [102, 103, 104].includes(nextCmd.code)) {
this._index++;
this.jumpTo(i + 1);
this._indent = this.currentCommand().indent;
switch (this.currentCommand().code) {
case 102:
this.setupChoices(this.currentCommand().parameters);
break;
case 103:
this.setupNumInput(this.currentCommand().parameters);
break;
case 104:
this.setupItemChoice(this.currentCommand().parameters);
break;
}
}
break;
}
}
};
})();
I decided to try this out with a complete blank project, and the issue still remains. While the text indeed can change, it stops choices from working (so if I press either yes or no, it won't show me "test 1/test 2" messages). So it seems like the plugin is working, but it breaks the choice system. For context, it's MZ, with 10.0 CoreScript.
Oh yeah, I forgot about _indent.
Add this line right after this.jumpTo(i + 1):
Or just copy the code from my previous post I updated it there.
Should fix it
Add this line right after this.jumpTo(i + 1):
JavaScript:
this._indent = this.currentCommand().indent;
Or just copy the code from my previous post I updated it there.
Should fix it
Yup, it fully works now, both in test and actual project. Thanks for help!
Original thread: https://forums.rpgmakerweb.com/threads/message-window-inside-the-conditional-branch-disappears-before-the-choice-list.182285/