- Joined
- Jul 2, 2014
- Messages
- 7,555
- Reaction score
- 5,324
- First Language
- English
- Primarily Uses
- RMMV
That sort() syntax you're referencing is a JavaScript method for arrays. The skillWindow isn't an array, it's its own Object of type Window_SkillList.Hello, I'd like to sort actors' skills in Window_SkillList/BattleSkill by MP cost. Can someone help me? I tried something like SceneManager._scene._skillWindow.sort(function(a, b) ... but I still can't get it right.
You can try applying that to the portion of the window's data that is an array. Try modifying the makeItemList() method from rpg_windows.js:
Code:
Window_SkillList.prototype.makeItemList = function() {
if (this._actor) {
this._data = this._actor.skills().filter(function(item) {
return this.includes(item);
}, this);
this._data.sort((a, b) => $dataSkills[a].mpCost-$dataSkills[b].mpCost);
} else {
this._data = [];
}
};
See how that works.