I'm currently trying to convert the tutorial Letting The Player Choose Their Character into a script as it's an unreadable mess and a pain to update as events only, however, I've ran into the issue of not knowing how to handle recursive choice selections. I saw the following threads Question about Nested Choices via JS and Message window doesn't show when called more than once but the first one isn't actually answered and the second one isn't script only. I'm not really sure on how to handle this. I'm sure there's a more complex character creation plugin, but I see no point in using one for something this simple.
I also saw this but it doesn't go into this either.
The code as-is:
I also saw this but it doesn't go into this either.
The code as-is:
JavaScript:
const characters = [
{ name: 'Kasey', class: 2, event_id: 26, image_id: 5, battle_image_id: "Actor1_5" },
{ name: 'Eliot', class: 3, event_id: 27, image_id: 6, battle_image_id: "Actor1_6" },
{ name: 'Roza', class: 3, event_id: 28, image_id: 7, battle_image_id: "Actor1_7" }
];
$gameMessage.add("Welcome Hero! It's time to face your destiny.\nNow, who are you?");
$gameMessage.setChoices(['Kasey', 'Eliot', 'Roza'], 1, -1);
$gameMessage.setChoiceCallback(index => {
character = characters[index]
$gameMap.event(character.event_id).moveStraight(2);
// TODO: Show selected character's actor image. Part of the Yes/No choice selection process
// TODO: Move this behind a separate yes/no choice selection
// If no, the character event_id moves back once and goes back to the character selection menu
$gameParty.members()[0].setName(character.name)
$gameParty.members()[0].changeClass(2, true);
$gameSwitches.setValue(2, true);
// Plays animation
const char = this.character(this._characterId = -1);
$gameTemp.requestAnimation([char], 117);
this.setWaitMode('animation');
// Changes the player's character
var actor = $gameParty.members()[0];
actor.setCharacterImage('Actor1', character.image_id);
actor.setFaceImage('Actor1', character.image_id);
actor.setBattlerImage(character.battle_image_id);
$gamePlayer.refresh();
// TODO: Have the event send a message saying the character was selected
});
this.setWaitMode('message');