While it will be fine doing so in many cases, in general loading and saving the game is not supposed to be done in the middle of the games update cycle
(when event commands would be run).
At this point, the events to update for the frame are already decided, and switching to a different savestate will continue updating those events, but many references to other events, switches, the player character etc. will use the freshly loaded data instead, which might trip the game up.
I'd recommend using a plugin for this one to move the execution of your loading script outside the main update routine:
Spoiler
Code:
// --------------------------------------------------------------------------
// After Map Update Routine
//
// @plugindesc Allows to reserve a script to be run after the map update
// cycle.
// @help Use
// $gameTemp.afterUpdate = function() {
// // ... your script ... //
// };
// to move the execution of your script outside the map update cycle.
// Scene switches caused by events (Battle Processing etc.) and the
// message box will take precedence over the reserved script.
//
// It's recommended to put this as close to the bottom of your plugin
// list as possible.
// --------------------------------------------------------------------------
(function() {
var sceneMapUpdateMain = Scene_Map.prototype.updateMain;
Scene_Map.prototype.updateMain = function() {
sceneMapUpdateMain.call(this);
if ($gameTemp.afterUpdate && this.isAfterUpdateOk()) {
var callback = $gameTemp.afterUpdate;
$gameTemp.afterUpdate = null;
callback();
}
};
Scene_Map.prototype.isAfterUpdateOk = function() {
return this.isSceneChangeOk();
};
})();
This should allow to alter your script call to
Code:
$gameTemp.afterUpdate = function() {
DataManager.loadGame(1);
$gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
SceneManager.goto(Scene_Map);
$gameSystem.onAfterLoad();
};
to move the execution of your script call and finish updating events and player first.
(Haven't tested the plugin yet though, but in general this should be a way to go)
As a sidenote, the
Code:
$gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
part is usually only done to reset the current map if the game has since been updated. It resets all events and parallel processes, which you might not want when loading the game normally. If that is the case you can make this part conditional and only reset the map if you updated your project since
(the default loading process):
Code:
if ($gameSystem.versionId() !== $dataSystem.versionId) {
$gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
}