ID:1594152
 
(See the best response by Kaiochao.)
Code:
        AIPath()

if(src.Repeat) world << "Repeat path"

if(Moves.len == 1) // If there's only 1 move in the list, walk in that direction
walk(src, ReadOrder(Moves[1]), 0, src.Speed)
world << "Walking"

else
world << "Good path"
for(var/dir in src.Moves) // Go through the entire list of moves
src.Command ++ // Add 1 to Command
var/counter = 0 // Reset counter each time through the loop
if(step(src, ReadOrder(dir)))
world << "Step returned 1"
while(step(src, ReadOrder(dir))) // Keep trying to move
world << "Projectile stuck"
sleep(1) // 1 tick delay between attemps
counter ++ // Add 1 to counter
if(counter >= 1000) del src
else
world << "Step returned 0"
world << "Stepped"
sleep(src.Speed)


Problem description:
This code doesn't work if I switch the if(step(src, ReadOrder(dir))) around. But the loop was only supposed to execute if step returned 0 (the step failed). So why does this work counter to what it should? Step returning 1 makes it attempt to step again. Step returning zero on a successful step.
Best response
Did you override Move() without returning the value of ..()?
Looks like I did