How to Use "Show Choices" in Javascript?

SumRndmDde

Follower of RNGesus
Veteran
Joined
Jul 30, 2013
Messages
225
Reaction score
423
First Language
English
Primarily Uses
RMMV
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...
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
check how is setup the Show choice in Game_Interpreter it's show how it's work
 

SumRndmDde

Follower of RNGesus
Veteran
Joined
Jul 30, 2013
Messages
225
Reaction score
423
First Language
English
Primarily Uses
RMMV
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:

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;};
 
Last edited by a moderator:

Sulsay

Villager
Member
Joined
Nov 25, 2015
Messages
25
Reaction score
7
First Language
Dutch
Primarily Uses
RMMV
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  :)
 

SumRndmDde

Follower of RNGesus
Veteran
Joined
Jul 30, 2013
Messages
225
Reaction score
423
First Language
English
Primarily Uses
RMMV
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.
 

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

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top