mob
NPC
icon = 'NPC.dmi'
New()
spawn() Walk_On_Path()
..()
proc
Walk_On_Path()
var/last
while(src)
var/list/valid = new/list()
for(var/x in dirs)
if(istype(get_step(src, x), /path))
world << "[x] is a path"
if(step(src, x))
world << "[x] isn't blocked"
if(x != turn(last, 180))
world << "[x] isn't the last dir"
valid += x
if(!valid.len)
world << "Put back in"
valid += turn(last, 180)
world << "----------------------"
for(var/x in valid)
world << "[x] is Valid"
world << "----------------------"
var/next_dir
if(valid.len)
next_dir = pick(valid)
if(istype(get_step(src, next_dir), /path))
step(src, next_dir)
last = next_dir
sleep(10)
Problem description:
Ok, for some reason if it goes to the far west of the path it will say that the area to the west is a path when in fact it isn't... The outputs are just for testing... If you have any questions please ask.
I know its not the best way to do it, but its my first attempt. Thanks in advance. [EDIT] Also, please just don't give me the solution, I don't want it. I want the reason mine doesn't work and how to improve it.[/EDIT]
-KirbyAllStar
If you don't want the object to move in order to test to see if it can move, use Enter. Get a variable to reference the turf in question, then check with if(turf.Enter(src)), and you will check to see if you can move without actually moving.