ID:264953
 
Code:
mob
var
build_type
GameMaster
verb
Custom_Map_Object()
var/obj/T = new(src)
T.name = input(src,"Name your turf.","Custom Turf") as text
T.desc = input(src,"Describe your turf. (Optional)","Custom Turf") as text|null
T.icon = input(src,"Choose an icon.","Custom Turf") as icon
T.icon_state = input(src,"Choose an icon state. (Optional)","Custom Turf") as text|null
build_type = T

turf
icon = 'base.dmi'
Click()
var/obj/O = usr.build_type
new O (locate(src.x,src.y,src.z))


Problem description:
runtime error: Cannot create objects of type /obj.
proc name: Click (/turf/Click)
usr: Warlord Fred (/mob)
src: the turf (6,9,1) (/turf)
call stack:
the turf (6,9,1) (/turf): Click(the turf (6,9,1) (/turf), "mapwindow.map", "icon-x=23;icon-y=21;left=1;scr...")


How can I copy an object without having to assign every variable of the first object to a new one?
If I remember correctly...
verb/CopyObj(/obj/oldObj)
var/obj/newObj = new
for(var/variable in oldObj.vars)
newObj.vars[variable] = oldObj.vars[variable]

In response to Zaoshi
That doesn't work, it's not writing to the variables.
An instance of an object is not the same as the type path of an object. O is an instance of an object of type /obj, not a type path. You would need to use O.type to create an object of the same type, not O. Additionally, you would need to copy over any variables you want copied over manually.
In response to Garthor
So the only way to duplicate an instance of an atom is to copy all the variables over manually?
In response to Warlord Fred
You could also utilize a temporary save file in order to make a copy of that object. As in:

var/savefile/F = new()
F << src
var/temp
F >> temp


However, while that is a little bit simpler, it does involve some file I/O (unless it's optimized away somehow, which I don't think so) and so would be considerably slower. For the purposes of a once-off, it may be viable however.