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,839
Reaction score
1,260
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
 

Latest Threads

Latest Posts

Latest Profile Posts

Another unscheduled stream for Lightestone~ this time because we hit affiliate! Aaaahh- So other than the game we're also going to work on emotes/badges/etc!

www.twitch.tv/riazey
Is it necroposting if I ask for more info in my own months old thread? All the information in the thread is relevant
JRPG TextBox HTML - Part 2:
So I'm resuming work on the Shadowstar Trilogy. I've decided that it will take place between the end of G4 and the start of G5, and two of the Lost Rulers will be Twilight Sparkle and Sunset Shimmer (who is the moon princess in my AU).

Forum statistics

Threads
108,971
Messages
1,040,940
Members
141,428
Latest member
Lark_Larkington
Top