How to Use "Show Choices" in Javascript?

All right, so I'm having some trouble with this.

I want to use "Show Choices" in Javascript, but I can't seem to figure out how to check to see which choice was chosen.

choices = []; params = [];$gameMessage.setChoices(choices, 0)choices.push("I love you1");choices.push("I love you2");choices.push("I love you3");choices.push("I love you4");choices.push("I love you5");choices.push("I love you6");choices.push("I love you7");choices.push("I love you8");params.push()
I got this from the RMMV Script Calls list, but it doesn't show how to check which one is selected...
check how is setup the Show choice in Game_Interpreter it's show how it's work
check how is setup the Show choice in Game_Interpreter it's show how it's work
Lol, wouldn't be asking here if it was that easy.

I already tried that, but I couldn't figure it out.

Here's the exact code from the Game_Interpreter if you or someone else thinks they can:

Spoiler
Code:
// Show ChoicesGame_Interpreter.prototype.command102 = function() {    if (!$gameMessage.isBusy()) {        this.setupChoices(this._params);        this._index++;        this.setWaitMode('message');    }    return false;}; Game_Interpreter.prototype.setupChoices = function(params) {    var choices = params[0].clone();    var cancelType = params[1];    var defaultType = params.length > 2 ? params[2] : 0;    var positionType = params.length > 3 ? params[3] : 2;    var background = params.length > 4 ? params[4] : 0;    if (cancelType >= choices.length) {        cancelType = -2;    }    $gameMessage.setChoices(choices, defaultType, cancelType);    $gameMessage.setChoiceBackground(background);    $gameMessage.setChoicePositionType(positionType);    $gameMessage.setChoiceCallback(function(n) {        this._branch[this._indent] = n;    }.bind(this));}; // When [**]Game_Interpreter.prototype.command402 = function() {    if (this._branch[this._indent] !== this._params[0]) {        this.skipBranch();    }    return true;}; // When CancelGame_Interpreter.prototype.command403 = function() {    if (this._branch[this._indent] >= 0) {        this.skipBranch();    }    return true;};
Hi there!

Try this: 

$gameMessage.add('Which one?');$gameMessage.setChoices(['One', 'Two'], 0, -1);$gameMessage.setChoiceCallback(function (choice) { // choice is the index of the selected option.}); The callback receives one argument; the index of the option that was chosen (so option 'One' would be 0, 'Two' would be 1).

The second argument for setChoices() is the default selection (where the cursor starts), and the third arg (-1) disallows canceling.

Let me know if this works out for you  🙂
Hi there!

Try this: 

$gameMessage.add('Which one?');$gameMessage.setChoices(['One', 'Two'], 0, -1);$gameMessage.setChoiceCallback(function (choice) { // choice is the index of the selected option.}); The callback receives one argument; the index of the option that was chosen (so option 'One' would be 0, 'Two' would be 1).

The second argument for setChoices() is the default selection (where the cursor starts), and the third arg (-1) disallows canceling.

Let me know if this works out for you  🙂
Thank you so much!

I'll go check to see if it works later.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-show-choices-in-javascript.51353/