(See the best response by Popisfizzy.)
Problem description:

So I'm trying to figure out exactly how storing references to specific, already-existing objects in the world works.
Like for example, I have an obj definition of a copper pickaxe, and in the map editor I place the pickaxe down in the world.
How do you reference THAT specific pickaxe?
And if you have, say, two pickaxes in the world and you want a mob to decide to go after one or the other to pick it up, how would you go about doing that?

My only real way to reference just the one pickaxe has been to use a for loop like:
for(var/obj/pickaxe/copper_pickaxe/p in world)
var/pick = p

But obviously this is a really crappy way to do thing. So how exactly do you go about referencing these things? Thank you!
I should say that the var/pick is actually defined outside the for loop, I was just typing in a rush. It would just be pick = p inside the for loop.
In the map editor, you can edit the placed obj's tag var to a unique text identifier, then at runtime get a reference to it with locate(tag).
You could find them as needed with
var p = locate(/obj/pickaxe) in locate(4,2,0)
or you could override the objects New proc and if it has a location then it was spawned on the map
In response to Kozuma3
Best response
Doing in hard code what you can do softly is the antithesis of good design.

Login to reply.