@Quxios: glad to have you back!
Some of your plugins use the "this" string when you can specify the event, either as a number or "this" string to refer to exactly that event.
This approach works in many cases, but not always...
I've figured out why it won't work for example when calling the plugin from Autonomous Movement > Custom > Route...
When in the Event Page (Right Hand) the
this keyword is a Game_Interpreter instance. This looks and works nice in almost every situation.
But when talking about the Autonomous Movement > Custom > Route... then
this keyword is a Game_Event instance.
That complicates things a bit, because the scope is different, also initialization of some extra variable members is required.
My solution at that time was to create a new Game_Interpreter object as a member of the event.
Everything below goes on a single line in the script, formatted for easier reading.
Code:
if (this.gameInterp===undefined){
this.gameInterp = new Game_Interpreter();
this.gameInterp._character=this;
this.gameInterp._eventId=this._eventId;
this.gameInterp._mapId = $gameMap.mapId();
}
this.gameInterp.pluginCommand('qPathfind', 'this chase p smart2'.split(" "));
The last 3 initializations in the if block are required, because Q Plugins need those values in order to properly process the "this" string that appear in the plugin line. But I also suspect more data could be required, maybe more stuff should be set up for a proper Game_Interpreter instance.
Example:
Inside Game_Interpreter.prototype.qPathfindCommand = function(args) {
Code:
var chara;
if (args[0].toLowerCase() === 'this') {
chara = this.character(0);
} else {
chara = QPlus.getCharacter(args[0]);
}
if (!chara) return;
The above code assumes that
character is a member/attribute of the
this keyword, But simply creating a new Game_Interpreter() won't give you the _character field initialized, nor will give it the _eventId or _mapId.
Just saying...
Other example, and this one I think is buggy... in every instance.
For some reason the above command throws an error when I use it in a map initialization event, that sets up a few things, and starts on autorun.
However, doing a
works fine.
Later edit: I think I found the issue in this last case, "this" string is just not processed inside the QPlus.getCharacter() function, is missing support for it.
Later Edit2: Because the Game_Interpreter.prototype.qPathfindCommand function is processing the string "this" on its own and is not relaying on QPlus.getCharacter() for this, then probably Game_Interpreter.prototype.qEventSaveCommand should do the same, and include the code:
Code:
var chara ;
if (args[1].toLowerCase() === 'this') {
chara = this.character(0);
} else {
chara = QPlus.getCharacter(args[1]);
}
BTW, did you had time to look in the Electron thread?
