Alright, nevermind, you are using pixel movement.

There's a useful function that I use for what you are trying to do:

#define TILE_WIDTH 32 //set these to your default icon size somewhere in your source code
#define TILE_HEIGHT 32

//changed with suggestions from Kaiochao. Note: This is does not make him less of a bastard. <3 Kaiochao. U know I keeeeed.

atom/movable
proc
CenterOn(atom/movable/Ref,X=0,Y=0)
if(istype(Ref))
loc = locate(Ref.x,Ref.y,Ref.z)
step_x = Ref.step_x + (Ref.bound_width - bound_width)/2 - bound_x + Ref.bound_x + X
step_y = Ref.step_y + (Ref.bound_height - bound_height)/2 - bound_y + Ref.bound_y + Y
else
loc = Ref
step_x = (TILE_WIDTH - bound_width)/2 + X - bound_x
step_y = (TILE_HEIGHT - bound_height)/2 + Y - bound_y


Rather than doing: usr.loc = locate(62,90,1), you can just call: usr.CenterOn(locate(62,90,1))

The reason that your player is showing up in weird spots is because their step_x/step_y variables are being preserved from before the teleport. This is why I was asking whether you were using pixel movement. I wanted to know whether the player was actually in the wrong location, or wether it appeared to be in the wrong location. If you were in tiled movement mode, appearing in the wrong location would have been pixel_x/y/z or transform-related. In pixel movement mode it could be either that or step_x/y, but it's definitely step related in your case.

Where the player is in the world is determined by loc, step_x, step_y, bound_x, and bound_y. These four variables affect where the player shows up and where their bounding box edges are located. If you want to relocate the player in pixel movement mode, you need to manipulate at the very least loc, but more than likely step_x and step_y too.
inconsistent indentation

And your indentation error is because you put the code at the wrong level or didn't convert from spaces to tabs. Easy fix. =D
Page: 1 2