Hi people!
I'm making one of my free plugins and I have a problem with a custom game object that I'm making to be stored in the save file. But, I'm using the ES6 syntax to write the class.
When I start a game, everything works fine.
When I save the game too.
But after I load a game, it only recognizes the objects inside him, but not the functions of the class(return undefined).
But, if I change the syntax to ES5(like rm mv use) everything works fine.
The case is that I really want to use ES6 syntax 😢
Here is a screenshot of the situation in the console:
And here is the code in case anyone wants to test it:
master.js
pupil.js
And here is the code, in case you don't want to download:
What I'm missing?
I'm thinking that maybe it has to do with a load function in DataManager, but I've searched and can't find a clue.
Also, I'm taking a look at this, in case it is a javascript error and not a "don't understand the mv code properly".
Still, I can't find the light =/
I'm making one of my free plugins and I have a problem with a custom game object that I'm making to be stored in the save file. But, I'm using the ES6 syntax to write the class.
When I start a game, everything works fine.
When I save the game too.
But after I load a game, it only recognizes the objects inside him, but not the functions of the class(return undefined).
But, if I change the syntax to ES5(like rm mv use) everything works fine.
The case is that I really want to use ES6 syntax 😢
Here is a screenshot of the situation in the console:
And here is the code in case anyone wants to test it:
master.js
pupil.js
And here is the code, in case you don't want to download:
JavaScript:
//==============================================================\\
// ES6 \\
//==============================================================\\
class Game_Eli{
constructor (){
this.initialize();
};
initialize(){
this.setObj();
};
setObj(){ // To be overwrited by plugin 2
};
};
//==============================================================\\
// ES5 \\
//==============================================================\\
// function Game_Eli() {
// this.initialize.apply(this, arguments);
// }
// Game_Eli.prototype.initialize = function(){
// this.setObj();
// };
// Game_Eli.prototype.setObj = function(){ // To be overwrited by plugin 2
// };
//==============================================================\\
// DATA MANAGER \\
//==============================================================\\
var $gameEli = null;
var DataManager_createGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function() {
DataManager_createGameObjects.call(this);
$gameEli = new Game_Eli();
};
var DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
let alias = DataManager_makeSaveContents.call(this);
alias.eli = $gameEli;
return alias;
};
var DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
DataManager_extractSaveContents.call(this, contents);
$gameEli = contents.eli;
};
JavaScript:
Game_Eli.prototype.setObj = function (){
this._book = "Amazing!"
};
Game_Eli.prototype.getObj = function(){
return this._book;
};
What I'm missing?
I'm thinking that maybe it has to do with a load function in DataManager, but I've searched and can't find a clue.
Also, I'm taking a look at this, in case it is a javascript error and not a "don't understand the mv code properly".
Still, I can't find the light =/