Quite simply it doesn't, but that's because it doesn't load another map.
So the $gameMap object & $gamePlayer objects data isn't changed & as you said the dataMap also remains the same, which means it doesn't need to store any information. It just pushes the scene list to become the menu scene while still keeping the map scene. Then when the menu is canceled it just pops the scene from the list and resumes with the map scene.
That said... I ran into an issue with this before also where I use the Scene_Map as a base & that of course caused all the issues you are running into now.
It's a bit tricky honestly but it definitely did the job for me...
...Basically we store temporary transfer back to point data for the player to transfer back to once we are done with our new map like scene.
I think it's just easier to show the code, explaining it all is kind of hard lol
Here is a demo of a solution to this issue.
..Below is just a simple blank map type of scene that creates a choice window and stores the chosen text to Game Variable #1...
Very basic example:
Spoiler: Code
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Map Scene Type Demo
//=============================================================================
/*:
* @target MZ
* @plugindesc [RPG Maker MZ] [Tier 1] [Version 1.00] [CT_Bolt - Map Scene Type Demo]
* @author CT_Bolt
* @url https://ct-bolt.itch.io/
*
* @help CTB_MapSceneTypeDemoMZ.js
*
*/
var CTB = CTB || {}; CTB.MapSceneTypeDemo = CTB.MapSceneTypeDemo || {};
var Imported = Imported || {}; Imported["CTB_MapSceneTypeDemo"] = 1.00;
(($_$) => {
const NAMESPACE = 'MapSceneTypeDemo';
const PLUGIN_NAME = 'CTB_' + NAMESPACE;
$_$['Game_Map.prototype.tileset'] = Game_Map.prototype.tileset;
Game_Map.prototype.tileset = function() {
var v = $_$['Game_Map.prototype.tileset'].apply(this, arguments);
if (!v){v = {id: 0, flags: [], mode: 1, name: "", note: "", tilesetNames: [], meta: {}}};
return v;
};
$_$['Scene_Map.prototype.create'] = Scene_Map.prototype.create;
Scene_Map.prototype.create = function() {
$_$['Scene_Map.prototype.create'].apply(this, arguments);
$gameSystem._transferBackTo = null;
};
$_$['Window_MapName.prototype.open'] = Window_MapName.prototype.open;
Window_MapName.prototype.open = function() {
if (!$gameSystem._dontDisplayMapName){
$_$['Window_MapName.prototype.open'].apply(this, arguments);
};
$gameSystem._dontDisplayMapName = false;
};
$_$['Scene_MapTypeDemo.prototype.onMapLoaded'] = Scene_MapTypeDemo.prototype.onMapLoaded;
Scene_MapTypeDemo.prototype.onMapLoaded = function() {
if (SceneManager._previousClass === Scene_Map){
$_$['Scene_MapTypeDemo.prototype.onMapLoaded'].apply(this, arguments);
}else{
if (this._transfer) {
$gamePlayer.performTransfer();
}
this.createDisplayObjects();
};
};
})(CTB.MapSceneTypeDemo, this);
//-----------------------------------------------------------------------------
// Scene_MapTypeDemo
//
// The scene class of a map-like scene.
function Scene_MapTypeDemo() {
this.initialize(...arguments);
}
Scene_MapTypeDemo.prototype = Object.create(Scene_Map.prototype);
Scene_MapTypeDemo.prototype.constructor = Scene_MapTypeDemo;
Scene_MapTypeDemo.prototype.initialize = function() {
Scene_Map.prototype.initialize.call(this);
};
Scene_MapTypeDemo.prototype.create = function() {
Scene_Message.prototype.create.call(this);
$gameSystem._transferBackTo = $gameSystem._transferBackTo || {mapId: $gameMap._mapId, x: $gamePlayer._x, y: $gamePlayer._y};
$gameSystem._dontDisplayMapName = true;
$gamePlayer.reserveTransfer(-1, 1, 1, 0, 2);
this._transfer = $gamePlayer.isTransferring();
this._lastMapWasNull = !$dataMap;
if (this._transfer) {
DataManager.loadMapData($gamePlayer.newMapId());
this.onTransfer();
} else if (!$dataMap || $dataMap.id !== $gameMap.mapId()) {
DataManager.loadMapData($gameMap.mapId());
}
};
Scene_MapTypeDemo.prototype.onTransferEnd = function() {};
Scene_MapTypeDemo.prototype.updateMain = function() {
$gameMap.update(this.isActive());
$gameScreen.update();
};
Scene_MapTypeDemo.prototype.isPlayerActive = function() {
return false;
};
Scene_MapTypeDemo.prototype.isFastForward = function() {
return false;
};
Scene_MapTypeDemo.prototype.updateMenuButton = function() {};
Scene_MapTypeDemo.prototype.isMenuEnabled = function() {
return false;
};
Scene_MapTypeDemo.prototype.isMapTouchOk = function() {
return false;
};
Scene_MapTypeDemo.prototype.processMapTouch = function() {};
Scene_MapTypeDemo.prototype.isAnyButtonPressed = function() {
return false;
};
Scene_MapTypeDemo.prototype.onMapTouch = function() {};
Scene_MapTypeDemo.prototype.isSceneChangeOk = function() {
return this.isActive() && !$gameMessage.isBusy();
};
Scene_MapTypeDemo.prototype.createDisplayObjects = function() {
this.createSpriteset();
this.createWindowLayer();
this.createAllWindows();
this.createButtons();
this.createChoiceWindow();
this._itemWindow.activate();
};
Scene_MapTypeDemo.prototype.createChoiceWindow = function() {
this._itemWindow = new Window_ChoiceList();
$gameMessage.setChoices(['Choice A', 'Choice B', 'Choice C', 'Cancel'], 0, 3);
$gameMessage.setChoiceBackground(0);
$gameMessage.setChoicePositionType(1);
$gameMessage.setChoiceCallback(n => {
$gameVariables.setValue(1, $gameMessage.choices()[n]);
this.onItemCancel();
}, this);
this.addWindow(this._itemWindow);
};
Scene_MapTypeDemo.prototype.onItemCancel = function() {
if (SceneManager._previousClass === Scene_Map){
$gamePlayer.reserveTransfer($gameSystem._transferBackTo.mapId, $gameSystem._transferBackTo.x, $gameSystem._transferBackTo.y, 0, 2);
}else{
SceneManager.goto(SceneManager._previousClass)
};
};
For this small demo example i've just called from an event on the map like this:
(of course same thing can be done from a command on the menu, just have to setup the menu command)
Looks like this in-game:
Spoiler: In-Game Demo Video
Attach this plugin for convenience
😉
Hope that helps and at least provides some insight for ya.