ID:2252140
 
(See the best response by Kaiochao.)
im trying to make a proc like oview(), but instead the proc returns objects that are either in front, behind, to the left, to the right, of them. no diagonals. i have no idea on how to make this happen
Best response
The obvious, naive/unoptimized approach would be to simply "filter" the resulting list from oview() to only include the objects you want.
// get a list of objects to start with
var list/objects = oview(src)

// consider each object in the list
for(var/object in objects)

// get the dir from src to the object
var dir_to = get_dir(src, object)

// this is the conventional way of checking if a dir is diagonal (not cardinal)
if(dir_to & dir_to - 1)

// since the dir to the object is a diagonal, remove it from the list
objects -= object

// now objects only contains objects at a cardinal direction