ID:1096856
 
Sometimes you wanna access a turf that isn't necessarily by the thing you want to interact with. Sometimes it's a few steps away, sometimes further. I've made a little snippet that can be used to get that turf. Even better, using it with block() you ca do a variety of things. I'm not the best programmer, but here's what I've got.

    Get_Turf(loc, X, dir) // X is number of tiles away, dir is in direction
var/turf/T // This will be returned
T = get_step(loc, dir) ; X --
while(X)
if(!isnull(get_step(T, dir)))
T = get_step(T, dir) ; X --
else
break

return T
Do you by chance mean get_steps()?

Also, you're not actually returning T in your snippet.
Huh, how about that. Someone else came up with it before me.

Oops on the return. I've edited it back in but it seems kinda silly now.
what if I need a turf that is four steps north and three steps west??? :P
Oh, you think that's clever?

var/turf/T = Get_Turf(usr, 4, NORTH)
var/turf/T2 = Get_Turf(T, 3, WEST)


Covered it buddeh.
or you could do this

var/turf/T = locate(usr.x - 3, usr.y + 4, usr.z)


:P

sorry I'm just playing devil's advocate here
Well the idea behind Get_Turf() is that you don't need the stick computations into locate(). I was tired of having to keep track of "where" I was. Also I kept getting dysnumeric with "where" I wanted to go :(

But hey. I prefer this to using numbers. Others are free to use it. If they don't, that's okay.