ID:155796
 
Is there a simple way to do this? I'm at a bit of a loss...specifically mobs is my interest. I want to just copy and place the exact setup of mobs in a new location.
Do you also need to copy their variables? Or are the initial values acceptable?

Either way, you would start out by identifying the bottom-left position of the block you're copying from, and whenever you find an atom you want to copy, get the difference between that bottom-left and the atom's position (eg var/dx = atom.x - botleft.x). You would then place the atom's copy at the new bottom-left position you are copying to, plus that difference.
In response to DarkCampainger
I have no idea how to "copy" them programming-wise though. Can you give me a hint?
In response to OrangeWeapons
OrangeWeapons wrote:
I have no idea how to "copy" them programming-wise though. Can you give me a hint?

DarkCampainger wrote:
Do you also need to copy their variables? Or are the initial values acceptable?

Depends on what you mean by copy.

To create a duplicate of the type of an atom, just create a new atom of their type (eg new A.type(locate(newBotLeft.x+dx, newBotLeft.y+dy, newBotLeft.z+dz)))

If you also need to copy over each individual variable, you'll want to loop through the vars list and copy the values over. (obviously this can be dangerous for certain variables, and you'll probably want to set up a global list of variables not to copy over; minimally loc, contents, client, ect).
In response to DarkCampainger
Um...this may look insane...but it pieced together in my head, and here it is:

client/verb/dimension_shock()
var/creating
var/list/moblist
for(var/mob/M in world)
moblist.Add(M)
while(creating>world_pieces)
creating++
var/mob/MO = new(moblist[creating])
MO.loc = locate(MO.x+15,MO.y,MO.z)


Of course it doesn't work...for obvious reasons...of which I don't know.
In response to OrangeWeapons
This isn't C++, we don't have copy constructors ;)

First off, you should initialize creating to 0. Second, you probably want to be checking that creating is LESS THAN world_pieces (although it seems like it would make more sense just to loop through the moblist directly, or just handle everything under your initial for() loop).

Then you'll want to determine the location ahead of time, so you can pass it to new() and let it do the work for you (not to mention some mobs may expect a loc to be already set by New()).

To create a mob of the same type as the other, use new M.type(newLoc).

Since you seem to be struggling with this, here's an example of how I would do it:
client/verb/dimension_shock()
var/turf/T
for(var/mob/M in world)
if(isturf(M.loc))
T = locate(min(M.x+15, world.maxx), M.y, M.z)
new M.type(T)


If you left code out of your example that explains why you have it broken into so many steps, you'll have to be more specific so I know the context. (for example, what world_pieces is being used for)