MZ How to check if an actor has learned a skill on level up?

I'm using NUUN_Result which is a fairly robust plugin. However I would like to tweak a thing.

Around line 5300 within Scene_Battle.prototype.openLevelUpWindow there is this._resultLearnSkillWindow.show(); which I'd like to put in an if statement for if an actor has learned a skill on a level up, then show the window, otherwise don't. Just under that function there's the closeResultWindow function where I think I can just check if the resultLearnSkillWindow is open, then close it, otherwise don't do a thing.

I'm asking help to figure out how to create the if statement to check if an actor has learned a skill on leveling up.

I did find this:

Code:
Game_Actor.prototype.levelUp = function() {
    this._level++;
    for (const learning of this.currentClass().learnings) {
        if (learning.level === this._level) {
            this.learnSkill(learning.skillId);
        }
    }
};

But I don't know how to make that work within 'Scene', since it's 'Game_Actor'.

Again, any and all help is appreciated! Thanks!
Didn't check the plugin, but if that levelUp stuff happens before the result screen opens, can't you put in that levelUp function to turn a switch on when they learn a skill and then check that switch? If you need it per actor, make different switches for the actors. Then just turn off the switches afterwards.
Hey,

I have not tested it, but the plugin might already record whether skills are learned on level-up:
actor._learnSkill
should be an array of skill Ids that the actor just learned (so you could check for array.length > 0).
Thanks for the replies, everyone! I've been MIA for a bit because of a dank flu.
ANYWAYS, so far what I've tried hasn't yet worked, likely because I just don't have the grasp of how all the syntax works.

I appreciate the help, regardless!
Hey,

Sorry for the late reply, forgot about the thread a bit, but glad to read you are well again.

Not sure if you found a solution already or what you tried, my idea would have been something like this:
Spoiler
JavaScript:
Scene_Battle.prototype.openLevelUpWindow = function() {
    BattleManager.resultPage++;
    const actor = BattleManager.resultLevelUpActors[BattleManager.resultPage - 1];
    if (this._resultHelpWindow) {
        this._resultHelpWindow.hide();
    }
    if (this._resultLevelUpHelpWindow) {
        this._resultLevelUpHelpWindow.show();
        const text = LevelUpResultHelpName.format(actor.name(), actor._level);
        this._resultLevelUpHelpWindow.setText(text);
    }
    this._resultWindow.deactivate();
    this._resultLevelUpMainWindow.activate();
    this._resultGetItemWindow.page = 0;
    this._resultWindow.hide();
    this._resultActorExpWindow.hide();
    this._resultGetInfoWindow.hide();
    this._resultGetItemWindow.hide();
    this._resultLevelUpMainWindow.show();
    this._resultActorStatusWindow.show();
  
    if (actor._learnSkill.length > 0) {
        this._resultLearnSkillWindow.show();
    }
  
    this.resultLevelUpRefresh();
};
Although I have not tested it myself, so... maybe
Hey,

Sorry for the late reply, forgot about the thread a bit, but glad to read you are well again.

Not sure if you found a solution already or what you tried, my idea would have been something like this:
Spoiler
JavaScript:
Scene_Battle.prototype.openLevelUpWindow = function() {
    BattleManager.resultPage++;
    const actor = BattleManager.resultLevelUpActors[BattleManager.resultPage - 1];
    if (this._resultHelpWindow) {
        this._resultHelpWindow.hide();
    }
    if (this._resultLevelUpHelpWindow) {
        this._resultLevelUpHelpWindow.show();
        const text = LevelUpResultHelpName.format(actor.name(), actor._level);
        this._resultLevelUpHelpWindow.setText(text);
    }
    this._resultWindow.deactivate();
    this._resultLevelUpMainWindow.activate();
    this._resultGetItemWindow.page = 0;
    this._resultWindow.hide();
    this._resultActorExpWindow.hide();
    this._resultGetInfoWindow.hide();
    this._resultGetItemWindow.hide();
    this._resultLevelUpMainWindow.show();
    this._resultActorStatusWindow.show();
 
    if (actor._learnSkill.length > 0) {
        this._resultLearnSkillWindow.show();
    }
 
    this.resultLevelUpRefresh();
};
Although I have not tested it myself, so... maybe
Awesome, thanks! I'll take a look!

EDIT: Looking at what you did, it was exactly what I was trying to do but must have just had the syntax wrong, so thank you for giving me the proper scripting! Haha. I just tweaked it to have an else statement where on else that the learn skill window would be hidden (otherwise it would stay open if the next actor also leveled up but didn't learn anything) and it works great! Thanks so much!


Code:
Scene_Battle.prototype.openLevelUpWindow = function() {
    BattleManager.resultPage++;
    const actor = BattleManager.resultLevelUpActors[BattleManager.resultPage - 1];
    if (this._resultHelpWindow) {
        //this._resultHelpWindow.hide();
    }
    if (this._resultLevelUpHelpWindow) {
        this._resultLevelUpHelpWindow.show();
        const text = LevelUpResultHelpName.format(actor.name(), actor._level);
        this._resultLevelUpHelpWindow.setText(text);
    }
    this._resultWindow.deactivate();
    this._resultLevelUpMainWindow.activate();
    this._resultGetItemWindow.page = 0;
    this._resultWindow.hide();
    //this._resultActorExpWindow.hide();
    this._resultGetInfoWindow.hide();
    this._resultGetItemWindow.hide();
    this._resultLevelUpMainWindow.show();
    this._resultActorStatusWindow.show();
 
    if (actor._learnSkill.length > 0) {
        this._resultLearnSkillWindow.show();
    } else {
        this._resultLearnSkillWindow.hide();
    }
 
    this.resultLevelUpRefresh();
};

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-an-actor-has-learned-a-skill-on-level-up.176750/