ID:139149
 
Code:
image
proc
autojoin()
for(var/turf/t in oview(1, loc))
var/image/i = locate() in t
world << "[i?1:0]"
if(i && i.tag == tag)
world << 2
if(get_dir(loc, t) in list(1,2,4,8))
world << 3
i.icon_state = "[text2num(i.icon_state) | get_dir(t, loc)]"
icon_state = "[text2num(icon_state) | get_dir(loc, t)]"


// Elsewhere...
for(var/turf/t in getring(u, u.los+1))
var/image/i = image('los.dmi',t,,EFFECTS_LAYER + 1)
i.tag = "unit"
images += i

if(u.hdrv < u.los)
for(var/turf/t in getring(u, u.hdrv+1))
var/image/i = image('drive.dmi',t,,EFFECTS_LAYER + 1)
i.tag = "unit"
images += i

if(u.next_move)
for(var/turf/t in getline(u, u.next_move))
var/image/i = image('movement.dmi',t,,EFFECTS_LAYER + 1)
i.tag = "unit"
images += i

spawn for(var/image/i in images)
i.autojoin()
sleep(10) // sleep for debug


Problem description:
Everything compiles properly. When I run it and test it I can see the images, but they aren't autojoining. The only debug output I'm getting is 0, meaning it's not finding images in the turfs.
While the loc of the image is the turf, the turf does not actually contain the image in its contents, and so locate() won't find it. You will need to iterate through your list of images and look for one whose location is the turf, or store the data in some other way.
I haven't looked at much of the code except the first five lines*. Image objects are not derived from /atom; as such, they do not have a location. The argument called "loc" in the image() proc does not mean that it will be "located" there in the atomic sense, only that it will be displayed there. You will have to find a different want to keep track of your image objects.

*Hey, I'm in the middle of complicated and can't loose my concentration. When you paged me, I figured I'd at least give it a quick look and see if anything fundamentally wrong jumped out at me. There you go.
In response to Garthor (#1)
Alright. Thanks for the help. I'm thinking an associative list could solve my problem. Thanks again. :)