Fail to fully save an Object into game save

ravenhood

Veteran
Veteran
Joined
Feb 26, 2020
Messages
62
Reaction score
29
First Language
Chinese
Primarily Uses
RMMV
Hi, i created a simple function like this:
Code:
function Game_Emap() {
    this.initialize.apply(this, arguments);
}

Game_Emap.prototype.initialize = function() {
    this._origin = 0.5;
    this._hideEmap = false;
    this._x = 0;
    this._y = 0;
    this._opacity = 255;
    this._blendMode = 0;
    this._updateDelay =1;
};

Game_Emap.prototype.update = function() {
};

Game_Emap.prototype.getRotation = function(event) {
    var result = 0;
    switch(event._direction) {
        case 2:
            result = 180; break;
        case 4:
            result = 270; break;
        case 6:
            result = 90; break;
        case 8:
            result = 0; break;
        default:
            result = 0;
    }
    return result;
};
Then i tried to save it into Game's Save:
Code:
var $gameEmap = null;
var old1 = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
    old1.call(this);
    $gameEmap = new Game_Emap();
};

var old2 = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
    var contents = old2.call(this);
    contents.eMap = $gameEmap;
    return contents;
};

var old3 = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
    old3.call(this, contents);
    $gameEmap = contents.eMap;
};
But, only the init property of the Game_Emap object had been saved, the function getRotation hadn't been saved at all. I can't figure why is that? Game_Map object still have its all function saved just fine?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,695
Reaction score
1,113
First Language
Portuguese - Br
Primarily Uses
RMMZ
That is strange. Because I did something like that and managed to save.
Perhaps did you are using the self-invoking function?
JavaScript:
(function(){
    // your plugin code
})();
Because maybe the var $gameMap it in the local scope.
Don't know very well, I'm still always learning the mv code xD

But I leave to you my code, and you can compare.

JavaScript:
"use strict"

var Imported = Imported || {};
Imported.Eli_Book = true;

var Eli = Eli || {};
Eli.Book = Eli.Book || {};

Eli.Book.Parameters = PluginManager.parameters("Eli's_Book");
Eli.Book.Param = Eli.Book.Param || {};

function Game_Eli() {
    this.initialize.apply(this, arguments);
};

Game_Eli.prototype.initialize = function(){
    this.helpWindowsParameters();
    this.checkPointParameters();
};

Game_Eli.prototype.helpWindowsParameters = function(){};
Game_Eli.prototype.checkPointParameters = function(){};

var $gameEli = null;

Eli.Book.DataManager_createGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
    Eli.Book.DataManager_createGameObjects.call(this);
    $gameEli = new Game_Eli();
};

Eli.Book.DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
    let alias = Eli.Book.DataManager_makeSaveContents.call(this);
    alias.eli = $gameEli;
    return alias;
};

Eli.Book.DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
    Eli.Book.DataManager_extractSaveContents.call(this, contents);
    $gameEli = contents.eli;
};
 

ravenhood

Veteran
Veteran
Joined
Feb 26, 2020
Messages
62
Reaction score
29
First Language
Chinese
Primarily Uses
RMMV
@Eliaquim It's was really exactly as you said. Thank you :D I put it's inside self-invoke function and couldn't figure why until you told me
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top