New() // New Proc
..() // Biz as usual
src.AI() // Begin AI
AI() // AI Code
var/obj/Gold/T // Define T
var/X = 100 // Define X to be 100
for(var/obj/Gold/A in world) // Loop through gold in world
if(X > get_dist(src,A)) // If it's closer than the current X value (Changes with target)
T = A // Make Target that gold mine
X = get_dist(src,A) // Define X as the distance
if(isnull(T)) // If T is null
world << "[src] was unable to find a target!" // Debug
else // If T is not null
src.Target = T // Define Target to be that gold mine
world << "[src] has targetted the [src.Target]" // Debug
walk_towards(src, src.Target, 0, src.MoveDelay) // Walk to it
world << "[src] is walking"
return
Problem description:
I have 3 rocks on the map, it should be able to find at least one target, but target is always null. Any ideas on why?
Doesn't for() choose the closest target by default?