public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

Script crashing on save/load: proto's forgetting functions?

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: Script crashing on save/load: proto's forgetting functions?
  • Original author: geri_khan
  • Original date: November 8, 2015
  • Source thread: https://forums.rpgmakerweb.com/threads/script-crashing-on-save-load-protos-forgetting-functions.49864/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript

Summary

Hi, I've been trying to port some of my VX Ace scripts over and learning javascript as I go. I think it's going pretty well, though no doubt it could be much, much better. But I've met a problem that has me utterly stumped. I've created a new camera system that allows the camera to focus on any combination of the player, events, followers, and static points. It creates an object at "$gameMap._camera" that contains a lot of variables and functions needed for the camera. Since it's contained in $gameMap,...

Archived First Post

Hi, I've been trying to port some of my VX Ace scripts over and learning javascript as I go. I think it's going pretty well, though no doubt it could be much, much better. But I've met a problem that has me utterly stumped.

I've created a new camera system that allows the camera to focus on any combination of the player, events, followers, and static points.

It creates an object at "$gameMap._camera" that contains a lot of variables and functions needed for the camera. Since it's contained in $gameMap, it gets included in the save file automatically.

It's all working great, I think, but I've met a problem with saving and loading. After loading the game, functions in _camera seem to become undefined.

For example, here's a console.log of $gameMap before saving.

goodproto.png


And here it is after loading

badproto.png


The proto for Game_Camera is empty, all the functions are gone, and it crashes with "undefined is not a function" immediately after loading. I'm sure I must be missing something obvious but I have no idea what. Help?

The script can be found at https://dl.dropboxusercontent.com/u/65029315/Camera.js

There's stuff I'm not too happy with in there (storing/restoring backups ended up very clunky) and if you have feedback/pointers for the rest of the script they're welcome. But it's the stuff above that's breaking my back right now.

Thanks.

EDIT: So I found a way to hack it. The proto gets removed when the save extracter overwrites $gameMap, so this...

var gk_camera_DataManager_extractSaveContents = DataManager.extractSaveContents  DataManager.extractSaveContents = function(contents) {    var cam = $gameMap._camera.__proto__;    gk_camera_DataManager_extractSaveContents.call(this,contents);    $gameMap._camera.__proto__ = cam;    $gameMap._camera.restoreAfterLoad();  };works. But it does not feel good. It feels bad. So if there's a way I should be going about it (and I don't know why, but things like Game_Map and Game Event properly retain their protos when loaded) then I'd still like to hear it.

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rpg-maker-archive#js-learning

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar