ID:179319
 
how would you cancle a verb when it's going through it's steps?
for instance

/mob/verb/patrol
step(NOrth or whatever)
sleep(10)
step(east, or whatever)
sleep(10)


now say you clicked this 3 times which means it's doing this 3 times at the same time, how would you stop it from finishing it?
mob/verb/patrol
step(NOrth or whatever)
sleep(10)
step(east, or whatever)
sleep(10)

If you want to make it only patrol once if you click on it a dozen times...

mob/var/patroling
mob/verb/patrol
if(patroling) return
patroling = 1
step(NOrth or whatever)
sleep(10)
step(east, or whatever)
sleep(10)
patroling = 0

If you want it stop patroling when you tell it to, don't use sleep procs!
In response to Foomer
doh
I guess I'll have to put a warning in my game about patrol...
lol


what I want it to do is... you have monster ai... so the monster will attack even though it's patroling... but I want it to beable to stop patroling if you want it to...
for instance

I have it so patrol loops
it never stops patroling
I want to know how you make it stop patroling...
you know so people don't have to keep going to that mob and making it patrol...
but if you can't stop the patroling...
hmmm...
In response to JonSnow13
Make patrol a short loop that just continues until you stop it.
In response to Foomer
I suggest using Deadron's Event Loop library. That way you can have the mob patrol each time the event loop is called. Then when you want it to stop, just use something like Foomer suggested to prevent it from moving. Another option is to modify the Move() proc to stop the patrolling. Lots of ways to do this :)
In response to English
changing the Move() doesn't stop patrol...
changes keeps you in one spot once you turn move backo n you're still going :)
In response to JonSnow13
I'd use the EventLoop method and just have the mob patrol under certain circumstances.

Your right that Move() won't actually stop a patrol loop from executing, it just depends on how you want to handle this ;)
In response to English
I think I'll just take my patrol ability out until BYOND gets a way to stop it :)
In response to JonSnow13
It has a way...it's called coding it to stop.
In response to Nadrew
hehe ya I know...
but it's more of a convience thing...
I could make it stop after doing a full circle...
but then that would make maintenance tuff, considering you probably have 5 different guys patroling and every time they finish patroling you have to tell them to patrol again, and again...
In response to JonSnow13
Just call a repeating look telling them to patrol, then cancel the loop when you want them to stop.

mob/var/patrol = 1
mob/verb/patrol()
patrol = 1
while(patrol)
//step around or whatever
sleep(10) // or at least some
// or you'll get immense lag from it
mob/verb/stop_patrol()
patrol = 0
In response to Foomer
I haven't tried this yet...
but what I'm saying is I know all this but will it actually stop the loop?
stopping loops only really works for walk commands so far that I've tried... since they cancle eachother out if you start a new walk command...
In response to JonSnow13
Since it says while(patrol) it will continue to loop until patrol evaluates to 0. Once that happens the loop will stop.
In response to JonSnow13
JonSnow13 wrote:
I think I'll just take my patrol ability out until BYOND gets a way to stop it :)

I just spit milk all over my screen... here's 3 ways BYOND can do it:

One, make a variable defined under mob called "do_stop". In all of your repeating action verbs, follow each sleep() with the lines

if (do_stop == 1)
do_stop = 0
return

Two, make a variable that tracks what direction the mob is patrolling in, and another that tracks the number of steps it's taken so far. If the number of steps > patrol range, turn 90 degrees. If the direction is set to null, it will stop patrolling. Your proc/verb/whatever for stopping the patrol, of course, sets the patrol_direction to null. This also has the advantage of giving you a way to streamline your patrol code (just have it take one step in patrol_direction, increase steps by 1, check if direction is null and return if so, check if it's at maximum range, turn and reset steps if so, repeat), and making it more flexible.

Three, incorporate Deadron's event handler. This sort of thing is what it's designed for.

This is 3 ways. There's literally thousands. Note that I'm not giving you this help because you deserve it, or because I think you can profit from it. I'm doing so because "I think I'll just take my patrol ability out until BYOND gets a way to stop it :)" is the funniest thing I've seen all month.
In response to English
oh.

you see, this is why I'm buying the byond book :)
when I look on a web site I just go to the parts I'm looking for, and never mind to look at the rest, or I'll look at something that interests me. I never would have thought to look under while() and read about.
But with a book I will sometimes read it twice (if it's a good book and I haven't read it in awhile)
from page 1 until the end without skipping.

btw this still isn't working...
I'm gonna play with it a little
In response to JonSnow13
Actually, what you need to do it return the loop like this:

for()
if(patrol)
//do patrol stuff
else return