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
ID:1096856
Dec 24 2012, 6:27 pm (Edited on Dec 24 2012, 6:46 pm)
|
|
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.
|
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. |
Oh, you think that's clever?
var/turf/T = Get_Turf(usr, 4, NORTH) 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. |
Also, you're not actually returning T in your snippet.