ID:179219
 
I'm trying to check for the existence of /obj/tile instances in any adjacent coordinates using the code below, but I seem to always get a non-zero result even if usr is nowhere near an existing tile on the board. what am i doing wrong?

var/adjacent_tile = 0
var/x = usr.x
var/y = usr.y
var/obj/tile/T = locate(x,y+1,1)
if(T)
adjacent_tile ++
T = locate(x+1,y,1)
if(T)
adjacent_tile += 2
T = locate(x,y-1,1)
if(T)
adjacent_tile += 4
T = locate(x-1,y,1)
if(T)
adjacent_tile += 8
locate() will always return a turf.

What you want to do instead is search through each turf as you locate() it, and see if it contains a /obj/tile (you can do that as for(var/obj/tile/tile in T).)
In response to Spuzzum
thanks!