- Joined
- Jan 17, 2014
- Messages
- 67
- Reaction score
- 30
- First Language
- Spanish
- Primarily Uses
- RMMV
I begun to make a lot of plugin scripts, but I've noticed many of them are incompatible together, getting "Maximum Call Stack Size" error.
I usually overwrite the default function like this:
The thing is, after doing this twice in different plugins, even if I name the vars _saveFUCTION1 and _saveFUNCTION2 over the same original function, I get the error popping.
For example, I'm currently working on a time/date system for ingame, and I need to save it into the savefile.
In order to do this, I worked on a mid-plugin as a core to enable a simpler management of the savefile for the developer.
Save Plugin snippet:
Clock Plugin snippet:
Sometimes, it even happens with no other plugins involved:
What other ways can I get my code called by normal game flow?
I usually overwrite the default function like this:
Code:
var _savetheoriginalFUNCTION = FUNCTION; //Assume the function I call is named "FUNCTION", and it has no params
FUNCTION = function()
{
//do whatever I want before it does the normal work
_savetheoriginalFUNCTION.call(this);
//do whatever I want after it does the normal work
};
For example, I'm currently working on a time/date system for ingame, and I need to save it into the savefile.
In order to do this, I worked on a mid-plugin as a core to enable a simpler management of the savefile for the developer.
Save Plugin snippet:
Code:
var _saveTheOriginalCreateGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function()
{
_saveTheOriginalCreateGameObjects.call(this); //Throws the error
//$me_CustomSave= new ME_CustomSave();
};
Code:
var _saveTheOriginalSetupNewGame = DataManager.setupNewGame;
DataManager.setupNewGame = function() {
_saveTheOriginalSetupNewGame.call(this); //If you do this in two plugins, with the same or different variable names, Max Call Stack error.
};
Sometimes, it even happens with no other plugins involved:
Code:
var _saveTheOriginalSceneMenuCreate=Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function() {
_saveTheOriginalSceneMenuCreate.call(this);
this.createCalendarWindow(); //Create a customized window for the default menu with sample values.
};
