how do i make events disappear once they reach the edge of the map?

title

the events are spawned with yanfly event spawner if that changes anything
Moved to: Javascript Plugin Support

It would be nice to add a link to the plugin you are using in the future to help people help you out. 🙂

http://yanfly.moe/2018/09/14/yep-170-event-spawner-rpg-maker-mv/


So you create spawned events using:
Yanfly.SpawnEventAt(mapId, eventId, x, y, preserved)

So you clone an event that resides on a specific map.
What if I told you, you can build something inside that Event?

What if told you, you can set variables with the X and Y position of the current event?
What if I told you, you can make Conditional Branches to check if they are out of bounds?
Then you use an event command to run a plugin command.
Yanfly.DespawnEventID(eventId)
But how you get the eventid of the event that is about to be erased?
You have to previously set up a variable with the value of $gameMap.event(eventId)

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-events-disappear-once-they-reach-the-edge-of-the-map.107862/