I made myself a bit of code in a plugin I'm working on, and while I can have it run on every map via a script call manually put on the map where I want events to have their images be auto replaced with its relevant actor's character image, I am hoping for a way to have it automatically run when the map runs, or the events get created.
I'm not having luck finding a good place for this. I tried the event constructor which resulted in an infinite loop.
I've seen some examples of override/adding onto pre-existing functions via a plugin, but I can't find a good function for it.
Is there a particular function I should be taking advantage of?
and for context an example of a notetag is <AutoActor:1>, which via the below code I got it to replace with the appropriate actor's character.
I'm not having luck finding a good place for this. I tried the event constructor which resulted in an infinite loop.
I've seen some examples of override/adding onto pre-existing functions via a plugin, but I can't find a good function for it.
Is there a particular function I should be taking advantage of?
and for context an example of a notetag is <AutoActor:1>, which via the below code I got it to replace with the appropriate actor's character.
JavaScript:
DLemon.assignActors = function() {
for(let i = 0; i < $gameMap.events().length; i++){
var event = $gameMap.events()[i];
var note = event.event().note
if(note.startsWith("<AutoActor:")){
var idString = note.slice(11);
idString = idString.slice(0,-1);
var id = parseInt(idString);
var actor = $gameActors.actor(id);
event.setImage(actor.characterName(), actor.characterIndex());
}
}
}