Auto-Close Skill Learn Window[RMMV]

Okay, so this plugin request is very specific and very simple:

I'd like the Skill Learn System menu to close the entire main menu when it is exited out of (instead of closing to the pause menu).

The reason for this is singlefold:

• If the player is allowed to backpedal into the pause menu without giving the game time to run its common events, the actual effects of the skills learned don't take effect until after you close and re-open the menu.

So basically, instead of fiddling around with trying to get parallel processes to work in menus (No thanks) I'd rather just have the party system auto-close once you're done in the menu.

Here's my .js file from my game:

Here's the original Yanfly plugin: http://yanfly.moe/2015/11/14/yep-28-skill-learn-system/

Thank you!
The part you'll want to change is here, then. Assuming that once the skill confirm thing is done the whole thing is done, that is.

Code:
Scene_LearnSkill.prototype.onConfirmOk = function() {
    var skill = this._skillLearnWindow.item();
    var classId = this._commandWindow.currentExt();
    this.processLearnSkill(skill, classId);
    this._confirmWindow.close();
};

Just from a super quick skim through I'd say try adding this line:
Code:
    this.popScene();

so replace lines 1863-1868ish with this:
Code:
Scene_LearnSkill.prototype.onConfirmOk = function() {
    var skill = this._skillLearnWindow.item();
    var classId = this._commandWindow.currentExt();
    this.processLearnSkill(skill, classId);
    this._confirmWindow.close();
    this.popScene();
};

edit Actually, replace it with this:
Code:
Scene_LearnSkill.prototype.onConfirmOk = function() {
    var skill = this._skillLearnWindow.item();
    var classId = this._commandWindow.currentExt();
    this.processLearnSkill(skill, classId);
    this._confirmWindow.close();

    for (var i = SceneManager._stack.length; i > 0; i--) {
      this.popScene();
    }
};

this way it'll always quit to the first scene. So it'll always quit to Scene_Map, in this case, no matter if you go through the menu or use the plugin command.
Well, it doesn't work. I have a feeling I know why this is, though.

I don't know the least bit about coding, but it looks like the script is checking for a confirm ok (As in, you click "Ok" for "Yes I do want the skill"), however...

vUAHeZK.png


I am using the integrated menu.

Basically, I want you to be able to stay on the skill menu to pick out as many skills as you like, but when you hit the right mouse button to close the menu, it deposits you to Scene_map. Currently it doesn't do that. I really appreciate your help though!
In that case, find these lines:
Code:
Scene_LearnSkill.prototype.createCommandWindow = function() {
    var wy = this._helpWindow.height;
    this._commandWindow = new Window_SkillLearnCommand(0, wy);
    this._commandWindow.setHelpWindow(this._helpWindow);
    this._commandWindow.setHandler('class',    this.commandClass.bind(this));
    this._commandWindow.setHandler('cancel',   this.popScene.bind(this));
    this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
    this._commandWindow.setHandler('pageup',   this.previousActor.bind(this));
    this._commandWindow.setHelpWindow(this._helpWindow);
    this.addWindow(this._commandWindow);
};

and replace them with this:
Code:
Scene_LearnSkill.prototype.createCommandWindow = function() {
    var wy = this._helpWindow.height;
    this._commandWindow = new Window_SkillLearnCommand(0, wy);
    this._commandWindow.setHelpWindow(this._helpWindow);
    this._commandWindow.setHandler('class',    this.commandClass.bind(this));
    this._commandWindow.setHandler('cancel',   this.quitToMap.bind(this));
    this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
    this._commandWindow.setHandler('pageup',   this.previousActor.bind(this));
    this._commandWindow.setHelpWindow(this._helpWindow);
    this.addWindow(this._commandWindow);
};

Scene_LearnSkill.prototype.quitToMap = function() {
   for (var i = SceneManager._stack.length; i > 0; i--) {
     this.popScene();
   }
};
That didn't work - but wow, that was a fast reply. Very awesome 😀

[REDACTED - REMOVED VIDEO SINCE THE PROBLEM WAS SOLVED]

Here's a quick go-over of what I'd like it to do. This is what it looks like WITH the newest edit you gave me.

Thanks again for the quick response! That was great. 🙂
Ohh okay I see what you mean then xD

You know the drill-- find this:
Code:
Scene_Skill.prototype.onLearnCancel = function() {
    this._skillLearnWindow.deselect();
    this._skillLearnDataWindow.setSkill(null);
    if (this._classListWindow && this._actor.availableClasses() > 1) {
      this._skillLearnWindow.hide();
      this._classListWindow.show();
      this._classListWindow.activate();
      this._classListWindow.selectLast();
    } else {
      this._skillTypeWindow.activate();
      this._helpWindow.setItem(null);
    }
};

do this:
Code:
Scene_Skill.prototype.onLearnCancel = function() {
    for (var i = SceneManager._stack.length; i > 0; i--) {
      this.popScene();
    }
   
    // this._skillLearnWindow.deselect();
    // this._skillLearnDataWindow.setSkill(null);
    // if (this._classListWindow && this._actor.availableClasses() > 1) {
    //   this._skillLearnWindow.hide();
    //   this._classListWindow.show();
    //   this._classListWindow.activate();
    //   this._classListWindow.selectLast();
    // } else {
    //   this._skillTypeWindow.activate();
    //   this._helpWindow.setItem(null);
    // }
};
Works like a charm! Thank you so much.

I'm making a text-based RPG (Not a JRPG in any sense of the word, more in common with western fantasy than anything). If you'd like a free copy of the game or some kind of creditation, feel free to ask.
Nah, I don't need anything like that. I'm happy that I was able to help, though! Good luck with your project ^^ it looks a bit like a dungeon-crawler, those are always fun.

Original thread: https://forums.rpgmakerweb.com/threads/auto-close-skill-learn-window-rmmv.96514/