I've got the Party Leader set to Game Variable 23, and I made it so that if you want to change the party leader, you simply select them in Formation Mode from the main menu and then select them again, and this changes Game Variable 23's value to that character's actor ID.
This is the edited code that I've got running in a plugin of Javascript changes. It's not entirely working correctly, though; in order for the change to go through, I have to exit out of the main menu and then go back in, and then select a leader -- then the Variable changes to whatever I tried to change it to previously. I've tried a variety of other little things, but none of them seem to do the job. Any help?
EDIT: Did some more work on it, still coming up bupkis. But I've identified where the issue is coming up:
It turns out that this does not give me the ID of the currently selected actor. It gives me the ID of the previous character I tried to make into the Leader (and if there was no previous character it defaults to 1). If I use a different number or just an integer it works like it's supposed to, select and reselect a character in Formation mode and the game variable changes to that number.
tl;dr: I just want to put the ID of a character selected in formation mode into a Game Variable
JavaScript:
Scene_Menu.prototype.leaderSet = function() {
const actor = this.actor().actorId();
if (this._statusWindow.pendingIndex() === this._statusWindow.index()) {
$gameVariables.setValue(23, actor);
this._statusWindow.refresh();
$gamePlayer.refresh();
};
};
Scene_Menu.prototype.onFormationOk = function() {
const index = this._statusWindow.index();
const pendingIndex = this._statusWindow.pendingIndex();
if (pendingIndex >= 0) {
this.leaderSet();
$gameParty.swapOrder(index, pendingIndex);
this._statusWindow.setPendingIndex(-1);
this._statusWindow.redrawItem(index);
} else {
this._statusWindow.setPendingIndex(index);
}
this._statusWindow.activate();
};
This is the edited code that I've got running in a plugin of Javascript changes. It's not entirely working correctly, though; in order for the change to go through, I have to exit out of the main menu and then go back in, and then select a leader -- then the Variable changes to whatever I tried to change it to previously. I've tried a variety of other little things, but none of them seem to do the job. Any help?
EDIT: Did some more work on it, still coming up bupkis. But I've identified where the issue is coming up:
JavaScript:
const actor =this.actor().actorId()
It turns out that this does not give me the ID of the currently selected actor. It gives me the ID of the previous character I tried to make into the Leader (and if there was no previous character it defaults to 1). If I use a different number or just an integer it works like it's supposed to, select and reselect a character in Formation mode and the game variable changes to that number.
tl;dr: I just want to put the ID of a character selected in formation mode into a Game Variable