What is a "comment event"? Oh - a
common event?
That function is called when the player cancels the formation command - they have not changed formation - they were going to, but they decided not to. So formation has not been changed.
If you want to run a common event after the player has changed formation,
this is the function you're after:
Code:
Scene_Menu.prototype.onFormationOk = function() {
var index = this._statusWindow.index();
var actor = $gameParty.members()[index];
var pendingIndex = this._statusWindow.pendingIndex();
if (pendingIndex >= 0) {
$gameParty.swapOrder(index, pendingIndex);
this._statusWindow.setPendingIndex(-1);
this._statusWindow.redrawItem(index);
} else {
this._statusWindow.setPendingIndex(index);
}
this._statusWindow.activate();
};
The best way would be to turn on a switch after the formation has been changed (after the $gameParty.swapOrder command, which is what changes the formation). Then create a common event that's set to autorun or parallel process, depending on what it's going to be used for, and uses that switch as its condition. The common event would need to turn the switch off again at the end.
This is the change you'll need to make - the example turns on switch 18, so change 18 to whatever switch you want to use:
Code:
if (pendingIndex >= 0) {
$gameParty.swapOrder(index, pendingIndex);
this._statusWindow.setPendingIndex(-1);
this._statusWindow.redrawItem(index);
$gameSwitches.setValue(18, true); // <--- this is the line you need to add
} else {
this._statusWindow.setPendingIndex(index);
}
It looks like
Adding this line
$gameSwitches.setValue(18, true);
Will just simplely turn switch on
This is my fault for not explaining well my question.
I want an common event to run in the menu especially when I change formation.
The reason is I am using multiple inventory by hime
And I made a common event to detect who's the leader and change the inventory
But common event won't run in menu by default
so if I change formation especially first member
it should change inventory but I need to close menu and reopen to activate it
However, if I don't close menu and just open item menu right after I change formation
inventory is not change
this may cause someone cheat when I finish my game and when someone find this bug
so I'm looking some way to solve this problem