ID:273150
 
Okay, let's say that I have a map on my second "z" level that I want to copy to another "z" level. Is there an easy way to do this, or do i have to check the type of every atom individually a create a function to duplicate every atom that way. Or is there a simpler method.
Use the select tool in the map editor to select everything then press ctrl+c to copy then go to a different z level and press ctrl+v to paste.
In response to Zaltron
I mean with code...
In response to Mr.Tophat
Mr.Tophat wrote:
I mean with code...

mob/verb/CopyZLevels()
var
zLevel2copyFrom = 1
zLevel2copyTo = 2
for(var/x = 1 to world.maxx)
for(var/y = 1 to world.maxy)
for(var/atom/a in locate(x, y, zLevel2copyFrom))
new a.type(locate(x, y, zLevel2copyTo))
In response to Zaltron
new a.type(locate(x, y, zLevel2copyTo))

[erased] ^ what was i was kinda looking for

Hrm, but even that code failed to create new turf and areas... on the different Z level
If you want to imitate the functionality of SwapMaps, why not learn from it?
In response to Schnitzelnagler
SwapMaps? I'll read into it, I've been away from Byond for a long time
In response to Mr.Tophat
Yes, sorry, thought you had been pointed at Lummox JR's SwapMaps Library in another posting already, but I guess I got confused and mixed up names.
Sorry, my apologies.
In response to Mr.Tophat
It should not have a problem with the turf part. I would have gone about it slightly different though.
// copies turf&area from z1 to z2
proc/copyTerrain(z1,z2, x1=1,y1=1, x2=world.maxx,y2=world.maxy)
// get a list of everything in the target area
var/list/L = block(locate(x1,y1,z1), locate(x2,y2,z1))
var/area/A
// loop through the target area
for(var/turf/T in L)
// create a turf of the same type as T in T's location on the other layer, and set its area
new T.type(locate(T.x,T.y,z2))
A = T.loc
A.contents += locate(T.x,T.y,z2)

Inside the for loop, you could add some other things if you want more aspects of the turf cloned, such as overlays/underlays, contents, etc.. If you clone contents, remember that you have to make clones of the contents of the original turf as well, and make sure you handle cloning them properly if you don't want reference issues or player-connection problems.