I can kind of do that. The problem is, every single way I have tried worked well with 1 map... But after 5+ maps, that were only 30x30 it got pretty laggy. So you can imaging what it would be like on a much larger scale.
From what I have worked out, the lag is coming from the game having to check which objects need to be deleted.
What I am doing is having a turf that every so often runs a proc.
When the server is started this turf creates a list of all turfs with the same z level as it.
When the proc is ran it will try to delete every object off the map first, then it will use pick to pick several turfs on the map then create objects at that location.
I am pretty sure this causes little to no noticeable lag at all. I've tried it without deleting other mobs/objs on the map and I didn't notice any real lag (until it had ran a few times and had created a ton of stuff).
Anyway, the problem I am having is with coming up with a decent method to delete the objects.
I've tried using...
for(var/obj/O in range(Range,T))
del O
But it doesn't seem to work properly, for some reason no matter what range I set it to, it just wont delete objects that are at the edge of the map.
I've tried using...
for(var/obj/O in world)
if(O.z==T.z)
del O
This works, but it is just way to laggy to actually use.
And I've tried...
for(var/obj/O in block(locate(1,1,T.z),locate(Range,Range,T.z)))
del O
This just refused to work all together, I have no idea why. Maybe because it is a turf calling the proc?
I even tried giving every mob/item an inactive timer, where after not seeing a player for so long they would delete themselves. But even that caused lag :[
So, is there anyway of clearing an inactive map of all mobs and objs and then having it respawn random mobs and objs in random locations on the map WITHOUT it causing to much lag :[?
And just so you know, I am talking about doing this on a scale of... 50-100 maps, starting off at 30x30 in size and gradually increasing up until around 50x50/100x100 (depending on how many map there is).