MV How to iterate through all $gameMaps

I am using Yanfly Event Spawner to create events in the world, and it seems that there is no way to know if I have spawned an item in other maps. Therefore, I believe the best approach is to iterate through all of them.

How can I do it?
you cannot - but spawned events are not stored in the mapfiles either, because those are basically read-only.
Only one map exists in memory - the current one. Transfering to a different map deletes all current map data and loads the next map from the data-files.


This also means that the event spawner stores the spawned events outside the mapfiles - and that is the data structure you'll have to iterate.

Unfortunately I don't know where or how that plugin stores its data, but it is completely within the plugin code where those parts are.
i made a plugin to store all event self switches in a global var, in order to better visually see it via console..
this stores also all events of all maps..
not sure if that also include yeps eventspawner events properly, because i use galvs eventspawner (and made my plugin compatible to that plugin)

not sure if thats usefull for your case but you can try it out

edit:

-> if yeps spawned events are still real game events, then my plugin will store them from all maps,which have been already visited by the gameplayer..
..and my plugin also offers functions to access them.

=> storing the events of all visited maps, wasnt my main purpose , its more a side-effect

https://forums.rpgmakerweb.com/index.php?threads/ess_storage-js.152796/

2023-06-30 04_20_42-ESS_Storage.js _ RPG Maker Forums – Mozilla Firefox.png


this plugin also allows to access self switches directly via game event, which is not possible by default..
Thank you!

Using that info I was able to understand how the map and events work and I found a way to find all the spawned events in all the maps!

JavaScript:
for (var mapId in $dataMapInfos) { // iterate all the maps
  var map = $dataMapInfos[mapId]; // store map info
  if(map && $gameSystem.getMapSpawnedEventData(mapId).length>1){ // Yanfly stores spawns here
    console.log(map.name); // Prints the map name
  }
}

Original thread: https://forums.rpgmakerweb.com/threads/how-to-iterate-through-all-gamemaps.158828/