The sheet this post links to: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/ explains well how to actually show choices, but does not explain how to actually respond to the user maing a choice. For example, I would like to show the user a text that depends on their choice. How to do that?
Having glanced at rpg_objects.js I figured that I should probably call $gameMessage.setChoiceCallback with a function tha handles the user's choice. So I thought I had to do something like this:
Code:
$gameMessage.setChoiceCallback(function(n) {
switch(n) {
case 0:
$gameMessage.add('Affirmative!')
break
case 1:
$gameMessage.add('Negative!')
break
}
})
$gameMessage.setChoices(["Yes", "No"], 0)The problem is that this is not working. The text is not being shown. The lines: $gameMessage.add('...') seem to be ignored.
I thought that supplying setChoiceCallback with a custom function was the way to do this because this function is indeed being called whenever the user makes up his mind and the parameter does equal to the number of the user's choice. This, for example, works as expected:
Code:
$gameMessage.setChoiceCallback(function(n) {
switch(n) {
case 0:
window.alert('Affirmative!')
break
case 1:
window.alert('Negative!')
break
}
})
$gameMessage.setChoices(["Yes", "No"], 0)I also thought that I was correctly trying to display a text from a script, as a script containing only this line works as expected and does display the text:
Code:
$gameMessage.add('Some Text')So what am I doing wrong? How to display a text depending on the choice the user makes?