RPG Maker Forums

What is the correct method to use if I want to alias DataManager.onLoad in multiple plugins?


If I use this for both of them:


var _DataManager_onLoad = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad(object);
// do my stuff here
};


the method in the second plugin calls the method in the first plugin, which calls the original method.  All three pass $dataActors as the object.  But I get an undefined is not a function error on rpg_managers 141: this.extractMetadata(data);


If I give them different alias names:


var _DataManager_onLoad1 = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad1(object);
// do my stuff here
};


and


var _DataManager_onLoad2 = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad2(object);
// do my stuff here
};


I get the same results.


On the this.extractMetadata(data) line it's telling me this is Window, but it's not listing extractMetadata as an available function.  When I disable both plugins and put a breakpoint on that line, it's telling me this is DataManager.  So I can see the context/scope is being shifted somewhere.


If I pass in this as a first argument:


var _DataManager_onLoad1 = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad1(this, object);
// do my stuff here
};


and


var _DataManager_onLoad2 = DataManager.onLoad;
DataManager.onLoad = function(object) {
_DataManager_onLoad2(this, object);
// do my stuff here
};


the second plugin says this is DataManager and object is $dataActors, but when it gets through to the first plugin, it says this is Window and object is DataManager.  It then passes DataManager through to the original function instead of $dataActors, so nothing gets processed.


It doesn't seem to matter whether I use the same variable name for the aliases or not.


The second function is calling the first function, and the first is calling the original, but I can't seem to get the right results, whether I include this as an argument or leave it out.  What do I need to do so it passes through the correct arguments and knows that this is DataManager in each case?

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,546
Members
137,835
Latest member
yetisteven
Top