proc
ai()
spawn(src.delaytime) while(src)
world<<"loop while1, (while(src)"
if(!src.target)
world<<"I have no target."
step(src,src.dir)
for(var/mob/m in world)
if(m.playing)
world<<"Found [m], targetting."
src.target=m
break
break
var/mob/n=src.target
while(n in world)
if(!n.playing)
world<<"Lost my target. restarting the procedure."
break
src.ai()
else
world<<"[n] is still alive. waiting my delay time to step towards him."
sleep(src.delaytime)
step_towards(src,src.target)
Problem description:
I'm probably doing something really really stupid, but it's gotten to the point where it freezes up when I try stuff >_> What am I doing? :/
--I also only started using the 'break' function for this, so perhaps I'm not using it correctly, but I suspect an infinite loop that I cannot spot >_>
Why are you looping through every mob to get a target when you can use locate()?
The big problem is probably just that you aren't sleeping where you should be, though. Sleep every time you have it do a loop.
Your src.ai() line will just call more procs and slow the program down (if you didn't break before it, at least >_>)
Efficiency note: while(src) is the same thing as plain old for(), but less efficient because it checks src every loop.
How break works: You can view break as the return of a loop in a sense. It completely ends the loop it's in.
You can also use labels to break loops higher up in the chain.