$gameSystem.removeCustomEvent($gameMap._mapId, eventId);
$gameSystem.clearCustomEvents($gameMap._mapId);
I'm wondering the implications of having a map where events will be copied in, last a few moments then be destroyed with the
delete this event
command.
With each event being added as a new eventid incrementally with its own number... and never restarting at 1 to replace any event that has been removed before it, will the large event id numbers start to cause lag or anything after a time???
Is there a way to clear out "used" ids so they can be grabbed for use by newly spawned in events??
for (var i = 0; i < $gameMap._events.length; i++) {
if ($gameMap._events[i]._erased) {
$gameMap._events[i] = undefined;
}
}
It will be cleared if the player leaves the map and comes back, but it will keep increasing while the player is still on the same map. If this is done hundreds of times, it may cause some lag on slower computers.
I'm not sure if anything bad will happen if I remove everything even while the map is running. Try running this piece of code in a parallel process from time to time and see if it works properly:
for (var i = 0; i < $gameMap._events.length; i++) {
if ($gameMap._events._erased) {
$gameMap._events = undefined;
}
}
for (var i = 0; i < $gameMap._events.length; i++) {
if (!!$gameMap._events[i] && $gameMap._events[i]._erased) {
$gameMap._events[i] = undefined;
}
}
Ah, of course. Small change:
for (var i = 0; i < $gameMap._events.length; i++) {
if (!!$gameMap._events && $gameMap._events._erased) {
$gameMap._events = undefined;
}
}
Worked like a charm, thank you.