Yes It's Plugin Command button (sorry)!
I'll try to be more detailed!
Plugins are those::
Call Event
www.yanfly.moe
Script Call Command
www.yanfly.moe
In the image attached you can see how I call plugins command.
I've an hypothesis:
The Call Event Plugin load the Map Data loading the text of the Map's Json file.
So If I'm in MAP 01 and I want to call the Event 1 of the MAP 2 the plugin load the text of MAP002.json and clone the Event properties in the Event in MAP 01 that launch the plugin command.
The problem maybe is that JS does not have a "wait read code" system so all lines of code are executed regardless of whether the previous one has finished and since the loading of the data map need "time" this does not happen before the other code is executed.
Now the question is: Why calling by Plugin Command Button works and Calling the same functions by script nope?!?
I checked how Yanfly bypassed the problem of "long loading" and I seen in the line about 146 He used a recursive function that "loop" until the necessary variables are populated
The function is this:
Code:
Game_Interpreter.prototype.processCallEvent = function() {
if ($callEventMap) {
this.insertCallEventData(this._callEvent_EventId, this._callEvent_PageId);
} else {
this.wait(1);
this._index--;
}
};
But there is a thing I not understand (and I think is the key of all)....Yanfly reiterated the function by the
this._index--; where "this" is a GameInterpreter object...
why decreasing the index the CALL EVENT function is executed again?
Another thing:
I need to do this because i need to
copy the event's pages (contained in the $dataMap object populated by the JSON load) array from an object GameEvent placed in a map to another GameEvent object placed in my map.
I hope I have been a little clearer now.
Thanks again for your help and sorry for my english but I'm writing from Italy :'D
Cya!