MV My advanced credits doesn't pop back to Scene_Map

I altered mog hunter's advanced credits. But I kept the SceneManager.pop() Function.

I have two places where the Advanced Credits scene happens: At the main menu, and at the end of the game.

I want to pop back to Scene_Map after the credits roll and the scene for the credits scene ends if coming from scene_map, or back to the title menu if done from title menu.

It runs perfectly through the title menu, but when run through the map, it will crash once the credits scene is complete.

Here's my code:

JavaScript:
//=============================================================================
// MOG_Credits_Adv.js
//=============================================================================

/*:
 * @plugindesc (v1.1) Adiciona a cena de créditos na tela de título.
 * @author Moghunter
 *
 * @param Number of Logos
 * @desc Quantidade de logos.
 * (Default = 1)
 * @default 1
 * @type number
 *
 * @param Credits Duration
 * @desc Duração do logo.
 * (Default = 60)
 * @default 60
 * @type number
 *
 * @param Credits Fade Duration
 * @desc Velocidade do fade.
 * (Default = 2)
 * @default 2
 * @type number
 *
 * @param Full Screen Mode
 * @desc Ativar o modo em tela cheia. (true  / false)
 * (Default = false)
 * @default false
 * @type boolean
 *
 * @help
 * @param Command Name
 * @desc Definição do nome do comando na tela de título.
 * @default Credits
 *
 * @param Scrolling Speed
 * @desc Velocidade de Scroll.
 * @default 1
 *
 * @help
 * =============================================================================
 * +++ MOG - Credits (v1.1) +++
 * By Moghunter
 * https://mogplugins.wordpress.com
 * =============================================================================
 * Adiciona a cena de créditos na tela de título.
 *
 * =============================================================================
 * UTILIZAÇÃO
 * =============================================================================
 * Serão necessários as imagens (img/system)
 *
 * CreditsA.png
 * CreditsB.png
 *
 * A altura da imagem pode ser de qualquer tamanho.
 *
 * =============================================================================
 * HISTÓRICO
 * =============================================================================
 * (v1.1) - Correção no efeito Background nas outras cenas.
 */

//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
  var Imported = Imported || {};
  Imported.MOG_Credits = true;
  var Moghunter = Moghunter || {};

   Moghunter.parameters = PluginManager.parameters('MOG_Credits_Adv');
    Moghunter.credits_commandName = String(Moghunter.parameters['Command Name'] || "Credits");
    Moghunter.credits_scrollSpeed = Number(Moghunter.parameters['Scrolling Speed'] || 1);
    Moghunter.credits_img_number = Number(Moghunter.parameters['Number of Logos'] || 4);
    Moghunter.credits_img_duration = Number(Moghunter.parameters['Credits Duration'] || 45);
    Moghunter.credits_img_fade_speed = Number(Moghunter.parameters['Credits Fade Duration'] || 1);
    Moghunter.credits_full_screen_mode = (Moghunter.parameters['Full Screen Mode'] || false);
   
    //=============================================================================
// ** Window Title Command
//=============================================================================  

//==============================
// * make Command List
//==============================
var _mog_credits_wtc_makeCommandList = Window_TitleCommand.prototype.makeCommandList;
Window_TitleCommand.prototype.makeCommandList = function() {
    _mog_credits_wtc_makeCommandList.call(this);
    this.addCommand(String(Moghunter.credits_commandName),   'mcredits');
};  
   
//=============================================================================
// ** Scene Tittle
//=============================================================================  

//==============================
// * create Command Window
//==============================
var _mog_credits_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
    _mog_credits_createCommandWindow.call(this);
    this._commandWindow.setHandler('mcredits',  this.commandMCredits.bind(this));
};

//==============================
// * command MCredits
//==============================
Scene_Title.prototype.commandMCredits = function() {
    this._commandWindow.close();
    this.fadeOutAll();
    SceneManager.push(Scene_MCredits);
};


//=============================================================================
// ** Scene M Credits
//=============================================================================  

//==============================
// * create Command Window
//==============================
function Scene_MCredits() {
    this.initialize.apply(this, arguments);
}

Scene_MCredits.prototype = Object.create(Scene_MenuBase.prototype);
Scene_MCredits.prototype.constructor = Scene_MCredits;

//==============================
// * initialize
//==============================
Scene_MCredits.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
};

//==============================
// * Create Mbackground
//==============================
Scene_MCredits.prototype.create_mbackground = function() {
};

//==============================
// * create
//==============================
Scene_MCredits.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    AudioManager.playBgm({name: "Stand_in_the_Rain", volume: 90, pitch: 100, pan: 0})
    this.createPictureCredit();
};

//==============================
// * create
//==============================
Scene_MCredits.prototype.createPictureCredit = function() {
    this._credits_data = [0,0, Math.max(Moghunter.credits_img_duration,1),Math.max(Moghunter.credits_img_fade_speed, 1)];
    this._credits_data.active = true;
    this._credits_img = [];
    this._credits_sprite = new Sprite();
    this._credits_sprite.anchor.x = 0.5;
    this._credits_sprite.anchor.y = 0.5;
    this._credits_sprite.x = Graphics.boxWidth / 2;
    this._credits_sprite.y = Graphics.boxHeight / 2;
    this.addChild(this._credits_sprite);
    for (i = 0; i < Moghunter.credits_img_number; i++){
        this._credits_img.push(ImageManager.loadSystem("Credits_Text_Img_" + i));
    };
    this.refresh_credits_screen();

};

//==============================
// * Refresh credits Screen
//==============================
Scene_MCredits.prototype.refresh_credits_screen = function() {
   if (this._credits_data[0] >= this._credits_img.length && this._credits_data.active == true) {
        this._creditsSpeed = Math.min(Math.max(Moghunter.credits_scrollSpeed,0.5),10);
        this.pictureCredit = [];
        this.pictureCredit.active = true;
        this.pictureCredit[0] = new Sprite(ImageManager.loadSystem("CreditsA"));
        this.pictureCredit[0].opacity = 0;
        this.addChild(this.pictureCredit[0]);
        this.pictureCredit[1] = new Sprite(ImageManager.loadSystem("CreditsB"));
        this.pictureCredit[1].y = Graphics.boxHeight;
        this.pictureCredit[1].opacity = 255;  
        this.addChild(this.pictureCredit[1]);      
       return;
   };
   this._credits_sprite.bitmap = this._credits_img[this._credits_data[0]];
   this._credits_sprite.opacity = 0;
   this._credits_data[0] += 1;
   this._credits_data[1] = this._credits_data[2];
   if (this._fade_data) {
       this._fade_sprite.bitmap = this._fade_img[this._fade_data[0]];
       console.log (this._fade_sprite.bitmap);
       this._fade_sprite.opacity = 0;
       this._fade_data[0] += 1;
       this._fade_sprite[1] = this._fade_sprite[2];          
    }                
};

//==============================
// * Start
//==============================
Scene_MCredits.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    this.startFadeIn(this.fadeSpeed(), false);
};


//==============================
// * Press Any Key
//==============================
Scene_MCredits.prototype.pressAnyKey = function() {
    if (TouchInput.isTriggered()) {return true};
    if (TouchInput.isCancelled()) {return true};
    if (Input.isTriggered("ok")) {return true};
    if (Input.isTriggered("cancel")) {return true};
    return false;
};

//==============================
// * Update
//==============================


//==============================
// * Update
//==============================
Scene_MCredits.prototype.update = function() {
    Scene_Base.prototype.update.call(this);
    if (this._credits_data[0]) {
        if (this._credits_data.active == true) {
            if (this._credits_data[1] <= 0) {
                this._credits_sprite.opacity -= this._credits_data[3];
                if (Input.isTriggered("ok") || TouchInput.isTriggered()) {this._credits_data[0] = this._credits_img.length};      
                if (this._credits_sprite.opacity <= 0) {this.refresh_credits_screen()};
            }
            else {
              this._credits_sprite.opacity += this._credits_data[3];
              if ((Input.isTriggered("ok") || TouchInput.isTriggered()) && this._credits_sprite.opacity > 60) {
                  this._credits_data[1] = 0; this._credits_data[0] = this._credits_img.length};
              if (this._credits_sprite.opacity >= 255) {this._credits_data[1] -= 1};
            }
        }
    }
    if (this.pictureCredit && this.pictureCredit.active == true) {
        this._credits_data.active = false;
        this.pictureCredit[0].opacity += 1;
        this.pictureCredit[1].y -= this._creditsSpeed;
        if (this.pressAnyKey() && !this.flaggie){
            this.pictureCredit[1].y = -this.pictureCredit[1].height;
//            this.fadeOutAll();
            SoundManager.playCursor();
            this.createBlackFade();
            };    
        if (this.pictureCredit[1].y < -this.pictureCredit[1].height && !this._fade_img && !this.flaggie){
            this.createBlackFade();
            };
        if (this._backgroundSprite) {this._backgroundSprite.visible = false};
    }
   if (this._fade_data) {
        this._fade_sprite.opacity += this._fade_data[3];
        if (this._fade_sprite.opacity >= 255) {
            SceneManager.pop();
        };
    }
    if (this._fade_img) {
        this._fade_img[0].opacity += 1;
/*         if (this.pressAnyKey()) {
            //this.fadeOutAll();
            SoundManager.playCursor();
            SceneManager.pop()
            }; */
    }
};

//==============================
// * create
//==============================
Scene_MCredits.prototype.createBlackFade = function() {
    this.pictureCredit.active = false;
    this._fade_data = [0,0, Math.max(60,1),Math.max(2, 1)];
    this._fade_img = []
    this._fade_sprite = new Sprite();
    this._fade_sprite.opacity = 0;
    this._fade_sprite.anchor.x = 0.5;
    this._fade_sprite.anchor.y = 0.5;
    this._fade_sprite.x = Graphics.boxWidth / 2;
    this._fade_sprite.y = Graphics.boxHeight / 2;
    this.addChild(this._fade_sprite);
    this._fade_img.push(ImageManager.loadSystem("Credits_Fade"));
    this.refresh_credits_screen();
    this.flaggie = true;
};
What engine are you using, MV or MZ?
And what is the exact error message you receive?
What engine are you using, MV or MZ?
he is using MV as its placed in MV.

I think the command only create it inside the title scene, not on scene Map which
should be added there too, or check if "sceneManager._scene instanceof Scene_Map" in order
to goto(Scene_Map) or something so the code knows what scene it was to pop it correctly.
he is using MV as its placed in MV.
Do you see something that I don't see? For me, this thread is in JS/Plugin support. Anyway...

I think the command only create it inside the title scene, not on scene Map which
should be added there too, or check if "sceneManager._scene instanceof Scene_Map"in order
to goto(Scene_Map) or something so the code knows what scene it was to pop it correctly.
Agree. I cannot see how you go from the map to the credits. We need to know your script or event call where you jump to the credit scene.
I use an un-altered mog's credit and it works fine for me calling the scene from the map or from the title. When on a map scene just use "SceneManager.push(Scene_MCredits);" in a scriptcall. It'll pop back out to the map when it's done.
So, what was happening (Sorry, overlooked a step), was that I was on a gameover scene before the credits. When I used pop();, it took me back to the gameover scene, but then exited, because the game over scene was already finished. What I did instead, to pop back to the scene map or scene title, (but in my updated case, I wanted to save the game, in case the player had completed the game for New Game+), is this:

JavaScript:
if (this._fade_data) {
        this._fade_sprite.opacity += this._fade_data[3];
        if (this._fade_sprite.opacity >= 255) {
            AudioManager.stopAll();
            if (SceneManager.isPreviousScene(Scene_Title))
                SceneManager.pop();
            else
                SceneManager.push(Scene_Save);
        };
    }

After this code, it would jump to either Scene_Save or Scene_title.

Original thread: https://forums.rpgmakerweb.com/threads/my-advanced-credits-doesnt-pop-back-to-scene_map.178230/