MZ cannot read property "page" of null

I'm making the event title using titleskip plugin
titleskip plugin :
https://forums.rpgmakerweb.com/index.php?threads/skip-the-title-screen-for-players.125548/

So I'm using script call to make a load and save, but there was an error.

The event call I'm using is as follows.

If I use the script below to load the file, an error occurs: cannot read property "page" of null

Spoiler: save
$gameSystem.setSavefileId(1);
$gameSystem.onBeforeSave();
DataManager.saveGame(1);

Spoiler: load
DataManager.loadGame(1)
.then(() => {
$gameSystem.onAfterLoad();
SoundManager.playLoad();
SceneManager._scene.fadeOutAll();
if ($gameSystem.versionId() !== $dataSystem.versionId) {
const p = $gamePlayer;
p.reserveTransfer($gameMap.mapId(), p.x, p.y, p.direction(), 0);
p.requestMapReload();
}
SceneManager.goto(Scene_Map);
}).catch(() => SoundManager.playBuzzer());


There is nothing wrong with the load screen. but, if i use a script call, an error occurs.
Hey muso,

we usually need the full console output. When you see the error, then
- Press F12
- in the window, navigate to "console"
- screenshot the full window
Hey muso,

we usually need the full console output. When you see the error, then
- Press F12
- in the window, navigate to "console"
- screenshot the full window
12.png

16.png

oh i didn't know that. this is the full screenshot of console
pages is probably the property of a map event in this case. If an event's ID is 0, the corresponding reference will be null. (If the ID is otherwise out of range, the event reference will be undefined instead, causing a slightly different error message.) No map event should have ID 0, though. 😅

Are you using any other plugins? If so, it may help if you share screenshot(s) of your Plugin Manager showing all plugins and their load order.
pages is probably the property of a map event in this case. If an event's ID is 0, the corresponding reference will be null. (If the ID is otherwise out of range, the event reference will be undefined instead, causing a slightly different error message.) No map event should have ID 0, though. 😅

Are you using any other plugins? If so, it may help if you share screenshot(s) of your Plugin Manager showing all plugins and their load order.
I turned off all the plugins and using script call, but the same error occurred.

But, I increased the number of events on the map that manage the title by the number of events on the map to load, and it was loaded without errors.

If there are more events, there are no errors, but if one is insufficient, an error occurs.

Is this relevant?
Thanks for the screenshot.

Are you teleporting to another map? It looks like the list of Game Events stays while you move to another map. So on your starting map, you had Event 5 (just as an example), but on your new map, it's missing.

I do a lot with map manipulation, so I know some tricks. In my code, I use this line right before "reserveTransfer" to remove all the Events.

Code:
$gameMap.events().forEach(event => event.erase());
Thanks for the screenshot.

Are you teleporting to another map? It looks like the list of Game Events stays while you move to another map. So on your starting map, you had Event 5 (just as an example), but on your new map, it's missing.

I do a lot with map manipulation, so I know some tricks. In my code, I use this line right before "reserveTransfer" to remove all the Events.

Code:
$gameMap.events().forEach(event => event.erase());

I don't know how my code works. I just pasted someone else's code.


I added the code you suggested, but the same error still occurred.
But do you do a Teleport from one Map to another one? Or what exactly do you do?
But do you do a Teleport from one Map to another one? Or what exactly do you do?
2.png

I used the code of the picture above as it is.

i want load the 1~3th slot data by script call.
View attachment 239216
I used the code of the picture above as it is.

i want load the 1~3th slot data by script call.
Hi there!
This did not answer aerosys question.
Can you answer if you are teleporting from one map to another? or if everything happens on the same map?

If you take a look at how the Scene_Load does the load, you will find this:
JavaScript:
Scene_Load.prototype.executeLoad = function(savefileId) {
    DataManager.loadGame(savefileId)
        .then(() => this.onLoadSuccess())
        .catch(() => this.onLoadFailure());
};

Scene_Load.prototype.onLoadSuccess = function() {
    SoundManager.playLoad();
    this.fadeOutAll();
    this.reloadMapIfUpdated();
    SceneManager.goto(Scene_Map);
    this._loadSuccess = true;
};

Scene_Load.prototype.onLoadFailure = function() {
    SoundManager.playBuzzer();
    this.activateListWindow();
};

Scene_Load.prototype.terminate = function() {
    Scene_File.prototype.terminate.call(this);
    if (this._loadSuccess) {
        $gameSystem.onAfterLoad();
    }
};

So one thing that I'm seeing different, is that you are calling the $gameSystem.onAfterload() BEFORE the SceneManager.goto(Scene_Map).
I guess you should try to do it in the same way, same order the Scene Load does, which is called the $gameSystem.onAfterload() when the Scene is terminating.
So put the $gameSystem.onAfterload() on the last line of the load success script.
It is just a guess, I don't know if it will work because I'm not so sure what is really triggering the error and why.
I turned off all the plugins and using script call, but the same error occurred.

But, I increased the number of events on the map that manage the title by the number of events on the map to load, and it was loaded without errors.

If there are more events, there are no errors, but if one is insufficient, an error occurs.
The script call you're using should reload the map if it has changed since the save was made...but if you saved during a (non-Parallel?) event, e.g. with a script call, then that old event will continue after the game is loaded. It's possible that the old event referenced something that no longer exists.

If it happens even when all plugins are off and works via the load screen, then as Aerosys said, I also think it might be related to your events. Could you share screenshots of your load/save events?

@Eliaquim - nice catch! By default onAfterLoad only updates the framecount and replays the saved BGM/BGS, so I don't think it's the culprit here. It's definitely an error in the script call, though! I'll correct that when I get a chance. 👋

Original thread: https://forums.rpgmakerweb.com/threads/cannot-read-property-page-of-null.150929/