MV Clone maps during runtime.

Given that plugins like YEP_EventSpawner save spawned events on the map itself, I was hoping for a way to clone maps into a new map ID during runtime. This would avoid some of the trouble of managing complex arrays for reconstructing data.

I don't know on a technical level how this plugin would work. I'm hoping its as simple as the plugin storing the "mother" map's ID and the "daughter" map's ID, per map generated this way, and then referencing those when entering the map.

Is there a way to do this? And have YEP_EventSpawner still work?
Cloning data objects is totally possible and not hard (I'm doing it in a WIP enchantment plugin), but maps are another story altogether. The problem with maps is that they essentially don't exist unless you're on them. So, there isn't a clear way to assign an ID to a cloned map.

Perhaps it would help if you explain your requirements in a bit more detail. Maybe there's a way that avoids the need to clone maps, or even if there isn't, it might help us to figure out what "cloning a map" means exactly for your problem.
Cloning data objects is totally possible and not hard (I'm doing it in a WIP enchantment plugin), but maps are another story altogether. The problem with maps is that they essentially don't exist unless you're on them. So, there isn't a clear way to assign an ID to a cloned map.

Perhaps it would help if you explain your requirements in a bit more detail. Maybe there's a way that avoids the need to clone maps, or even if there isn't, it might help us to figure out what "cloning a map" means exactly for your problem.
Basically, I want the game to create different towns and interiors by cloning a base map. The issue comes mainly from any attempt to add variation on top of that. EventSpawner needs to be able to distinguish one town generated based on a give map from another. Basically, EventSpawner needs to at least think they are different maps even if they are not.

Otherwise, I'd have to manage multi-dimensional arrays and I really don't want to deal with that headache.
Unfortunately, I don't know how EventSpawner works and can't see the code, so it's difficult to answer that question. It's likely possible. For example, if you wanted built-in self switches to recognize instances as separate maps, I think it wouldn't be that difficult to achieve – I recently did something like this.

But there still may be other approaches to consider… for example, are there a fixed number of clones for each map? To put it another way, is it something that theoretically could be handled by manually making N copies of each map and slightly tweaking each one? I don't mean to suggest that this is an approach you should try (if you have 50 maps, each of which have 100 variations, it's clearly not practical), but if the scenario is such that you could in principle do it, then that knowledge would help for working out a less tedious method to obtain the same effect.
Unfortunately, I don't know how EventSpawner works and can't see the code, so it's difficult to answer that question. It's likely possible. For example, if you wanted built-in self switches to recognize instances as separate maps, I think it wouldn't be that difficult to achieve – I recently did something like this.

But there still may be other approaches to consider… for example, are there a fixed number of clones for each map? To put it another way, is it something that theoretically could be handled by manually making N copies of each map and slightly tweaking each one? I don't mean to suggest that this is an approach you should try (if you have 50 maps, each of which have 100 variations, it's clearly not practical), but if the scenario is such that you could in principle do it, then that knowledge would help for working out a less tedious method to obtain the same effect.
I could in theory limit the number of maps which can be generated, but this would come with a couple of issues.

For one, it would add a significant amount of complexity to the generation system, because it would need to know which maps can be used. For example, the logic may call for a city fitting a set of criteria, and it would need to know if any valid map still has slot available.

For two, since EventSpawner can only despawn events on the current map, if I want to cull a map from the active maps, I'd need to temporarily transport the player to that map in order to clear it. Otherwise, it would maintain the events held on it by the previous use of that slot would remain, and likely exist alongside a new set of events spawned.
I could in theory limit the number of maps which can be generated, but this would come with a couple of issues.

For one, it would add a significant amount of complexity to the generation system, because it would need to know which maps can be used. For example, the logic may call for a city fitting a set of criteria, and it would need to know if any valid map still has slot available.
If I'm reading this right, I believe you're saying that there would be potentially an infinite number of map variations being generated. Is that correct?

For two, since EventSpawner can only despawn events on the current map, if I want to cull a map from the active maps, I'd need to temporarily transport the player to that map in order to clear it. Otherwise, it would maintain the events held on it by the previous use of that slot would remain, and likely exist alongside a new set of events spawned.
Again, with no knowledge of how EventSpawner works, it's almost impossible to draw a conclusion about this. Still, I'd tentatively guess that the limitation of despawning events only on the current map is not "real" – or to put it another way, that it's a case of "chose not to implement it" rather than "there is no way to do it".

Original thread: https://forums.rpgmakerweb.com/threads/clone-maps-during-runtime.178249/