ID:2051885
 
(See the best response by Lummox JR.)
Code:

This works as I would expect. The player is moved to z:3 and the output is 3.
var/obj/o = locate("[src.ckey]_Surface_Teleporter")
loc = locate(o.x, o.y, o.z)
world.log << "[z]"


This does not work and I'm not sure what to expect. The player is moved to z:3 but the output is 0.

loc = locate("[src.ckey]_Surface_Teleporter")
world.log << "[z]"


Why does the player move in this case but the players z var remains 0?

Best response
If the teleporter is an obj, then setting loc directly means your mob is inside the obj, not on its turf.

According to the source, a movable atom's x/y/z vars all read as 0 when it's not directly on a turf.
In response to Lummox JR
Lummox JR wrote:
If the teleporter is an obj, then setting loc directly means your mob is inside the obj, not on its turf.

OK, I can accept that but my z should still be equal to that of the obj I'm in, right?
In response to PopLava
PopLava wrote:
Lummox JR wrote:
If the teleporter is an obj, then setting loc directly means your mob is inside the obj, not on its turf.

OK, I can accept that but my z should still be equal to that of the obj I'm in, right?

*edit*, ah, there it is.
In response to PopLava
Thanks for the explanation. A little odd though. Wondering if that's the expectation people have when wanting to move to a tagged item. Wouldn't most people want to simply move to the object instead of inside it?
But setting loc = obj would never move to the obj's loc; the behavior it has is by definition.