Having some trouble loading a save file with script call...

I'm trying to manually initiate loading a save without going through 'Scene_Load'.

I have this script in my event:

JavaScript:
DataManager.loadGame(1)
SoundManager.playLoad();
SceneManager.goto(Scene_Map);
if ($gameSystem.versionId() !== $dataSystem.versionId) {
    $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
    $gamePlayer.requestMapReload();
}

I get this error: TypeError: Cannot read property '34' of undefined.
Tried messing around with it but I couldn't really find a solution, I humbly request your assistance.
I don't think this should be a big deal, but I also searched the forum and didn't come up with a working solution.


(By the way, when I use SceneManager.push(Scene_Load); in my event, loading the save from the load screen works great. There's no problem with saving/loading normally, so the problem must be in the code above. I don't want the player to go through the save screen since there's only one slot being used, like a checkpoint system.)
When you get that error, hit F8 to open the developer tools, find the Console tab, and grab a screenshot. My guess is that there's a plugin involved here - maybe you saved your game, added a plugin, and it requires something to be in the save file that isn't there. Without the full log, can't be sure.
When you get that error, hit F8 to open the developer tools, find the Console tab, and grab a screenshot. My guess is that there's a plugin involved here - maybe you saved your game, added a plugin, and it requires something to be in the save file that isn't there. Without the full log, can't be sure.

Good guess, Khas Ultra Lighting throws an error.
But I didn't add it between saving and loading (I save and then immediately try the loading event).

I don't see what's missing in my code, since I do the same thing that Scene_Load does, and when loading normally there's no problem.
Maybe I need to somehow stop the plugin before loading? Not sure what to do.

1592089126056.png
Does that plugin do anything special when it loads a game? Maybe you need to include something else in your script call.

If you can't figure it out, please go into that script and find line 599. Copy that function and paste it here, and indicate which line is 599.

Also, where are you putting that script in your game? Is it in an event, or have you created your own plugin, or modified the default scripts or another plugin? What is its context - when does it get called?

I've moved this thread to Javascript/Plugin Support. Thank you.

Does that plugin do anything special when it loads a game? Maybe you need to include something else in your script call.

If you can't figure it out, please go into that script and find line 599. Copy that function and paste it here, and indicate which line is 599.

Also, where are you putting that script in your game? Is it in an event, or have you created your own plugin, or modified the default scripts or another plugin? What is its context - when does it get called?
I use the code in an event, the player basically goes back to the previous check point.

Line 599 in the plugin is the return statement:
JavaScript:
  Game_Map.prototype.getHeight = function(x, y) {
    return this.isValid(x, y) ? this._heightMap[x][y] : null;
  };

This is the isValid function:
JavaScript:
  Sprite_Light.prototype.isValid = function() {
    return this._id ? true : false;
  };

And the height map is being set this way:
JavaScript:
  Game_Map.prototype.setHeight = function(x, y, h) {
    this._heightMap[x][y] = h;
  };

JavaScript:
  Game_Map.prototype.genHeightMap = function() {
    this._heightMap = [];
    for (var x = 0; x < this.width(); x++) {
      this._heightMap.push([]);
      for (var y = 0; y < this.height(); y++) {
        var h = Math.floor(this.regionId(x, y) / 10) * 2;
        this._heightMap[x].push(h);
      };
    };
    for (var x = 0; x < this.width(); x++) {
      for (var y = 0; y < this.height(); y++) {
        var h = this._heightMap[x][y];
        var nh = this.getHeight(x, y + 1);
        if (h > 0 && this.isFloor(x, y) && h > nh) {
          h -= 1;
          var dy = 1;
          while (h > 0 && (nh == 0 || h - 1 > nh) && this.isValid(x, y + dy)) {
            this.setHeight(x, y + dy, h);
            h -= 2;
            dy += 1;
            if (this.isValid(x, y + dy)) nh = this.getHeight(x, y + dy);
          };
        };
      };
    };
  };



I just don't get the difference between what Load_Scene does and what my own code does, it's basically the same code. I'm missing something... Maybe something is happening when the Scene_Load is being pushed.

Moved to: Javascript/Plugin Support
Thanks, I didn't think it was a plugin issue at first.

Original thread: https://forums.rpgmakerweb.com/threads/having-some-trouble-loading-a-save-file-with-script-call.122830/