MZ Add scene on top of another scene, without the first scene being reinitialized

Hello,

Like said in the title I'm trying to add a scene on top of another scene, but when I do that it terminates the first scene, and when the second scene is closed, the first one reinitializes.

My first scene:

JavaScript:
 PluginManager.registerCommand(plugin_name, "battle_1_1", () => {
    SceneManager.push(Scene_P1_Card_Battle);
  })

    function Scene_P1_Card_Battle() { Scene_Base.call(this) }
    Scene_P1_Card_Battle.prototype = Object.create(Scene_Base.prototype)
    Scene_P1_Card_Battle.prototype.constructor = Scene_P1_Card_Battle

    Scene_P1_Card_Battle.prototype.initialize = function() {
      Scene_Base.prototype.initialize.call(this)
        this.load_data()
        this.load_sprites()
    }

    Scene_P1_Card_Battle.prototype.create = function() {
      Scene_Base.prototype.create.call(this)
    }

    Scene_P1_Card_Battle.prototype.start = function() {
      Scene_Base.prototype.start.call(this);
    }

In the update function I call another plugin which will push another scene:

JavaScript:
          if (!this.dialogue_called) {
            this.dialogue_called = true
            PluginManager.callCommand(this, "cool_dialogues", this.cutscenes[this.current_cutscene].name, {})
          }

And in the other plugin:


JavaScript:
  PluginManager.registerCommand(pluginName, "C1_1_battle_intro", () => {
    SceneManager.push(Cool_Dialogues);
  })

  function Cool_Dialogues() {
    this.initialize(...arguments)
  }
  Cool_Dialogues.prototype = Object.create(Scene_Base.prototype)
  Cool_Dialogues.prototype.constructor = Cool_Dialogues

So what it does here is: load the first scene, at some point, the first scene will call the other plugin which will push another scene, but the first scene will terminate itself (call the stop and terminate function), after the second scene finished doing its thing, I will pop the scene so it goes back to the first one. But when I do that, it will call the initialize function again, and reload everything like it loaded the first time. So it completely resets.
But from what I understood, when you push a scene it shouldn't do that, it should just put the first scene in pause and resume when the second scene is over.

Do you know how I could fix this ?
I'm sorry if my explanation isn't very good, feel free to ask for more information
I think the "normal" way to handle this would be either:

  • Make them both the same scene, but the windows of Cool_Dialogues start out hidden. That's how the message window works, for example.
  • Make the P1_Card_Battle scene pick up where it left off when you later enter the scene again.

I don't know what it would take to actually have one scene on top of another, but it's working against the engine's design, so it's probably harder than doing one of the above.
I think the "normal" way to handle this would be either:

  • Make them both the same scene, but the windows of Cool_Dialogues start out hidden. That's how the message window works, for example.
  • Make the P1_Card_Battle scene pick up where it left off when you later enter the scene again.

I don't know what it would take to actually have one scene on top of another, but it's working against the engine's design, so it's probably harder than doing one of the above.
Hello, thanks for your reply, I'm a bit confused because I was pretty sure that the engine should handle stacking up scenes. It kinda already does it, the Map is a scene, and when you open the menu or something it stacks a scene on top of it.
I'm not 100% sure, but I think the map scene actually does end when you open a menu. Visually, it certainly looks like it's stacked, but as far as I know that's just a visual "snapshot" of the map before it ended.

Someone else can correct me if I'm wrong.
Yep, by default only 1 scene is active at a time.

Like @Solar_Flare says, the default pause menu background is a blurred snapshot. The map data (mainly $gameMap) is not stored on the scene, so it is unaffected. On exiting the menu, a new instance of Scene_Menu is created and initialised with the relevant data.
Yep, by default only 1 scene is active at a time.

Like @Solar_Flare says, the default pause menu background is a blurred snapshot. The map data (mainly $gameMap) is not stored on the scene, so it is unaffected. On exiting the menu, a new instance of Scene_Menu is created and initialised with the relevant data.
Hummm, I see, so basically I have to do all in the same scene like @Solar_Flare said, or find a way to store the data somewhere and reload it when the second scene closes :|

Aight I'll see thank you for the explanation, helps a lot

Original thread: https://forums.rpgmakerweb.com/threads/add-scene-on-top-of-another-scene-without-the-first-scene-being-reinitialized.178604/