ID:178974
 
Since walk_to() runs in the background and returns immediately, I was wondering how I should set up my code to perform other actions only AFTER the walk_to is truly complete. I could continuously compare the locations of REF and TRG (with a sleep between checks of course), but i'm sure there's a better way that many of you already know of.

Thanks!
There really isn't any great way to do this.

What a lot of us end up doing is abandoning walk_to() and writing our own specialized functions for whatever we need.

-AbyssDragon
In response to AbyssDragon
AbyssDragon wrote:
There really isn't any great way to do this.

What a lot of us end up doing is abandoning walk_to() and writing our own specialized functions for whatever we need.

-AbyssDragon

Is there any place I can find an example of one of these specialized functions?
Here's a crazy idea... Create a new area at the location of TRG, overide that area's Entered() proc to call the usr's do_this_after_walk_to() proc, which would handle your other stuff. Then, del the area.

~X
In response to Dramstud
It wouldn't be that hard to just write your own walk_to():

mob/proc
walkto(var/mob/ref,var/atom/target,var/delay) //target could be obj, mob or turf
while(get_dist(ref,target) > 1)
sleep(delay)
step_to(ref,target)
//do extra stuff here
In response to Xooxer
Xooxer wrote:
Here's a crazy idea... Create a new area at the location of TRG, overide that area's Entered() proc to call the usr's do_this_after_walk_to() proc, which would handle your other stuff. Then, del the area.

~X


Clever...

I'm not sure this tactic would fit my current need though -- the walk_to could get interrupted prematurely (thus TRG is never reached), but i would still need the other stuff to run afterwards.

I'm using a while(step_to()) loop for now.
In response to Dramstud
Ah, right. I didn't think about that. :P Told you it was crazy! I like your aproach... very quaint. hehe :)

~X
In response to Xooxer
Xooxer wrote:
Ah, right. I didn't think about that. :P Told you it was crazy! I like your aproach... very quaint. hehe :)

~X

I can't take credit for it though... I got help from a higher source.
In response to Dramstud
Just incase you used my example you might want to midify it with a spawn(). If you use it similar to my example then the proc that called walkto won't finish until the stepping is done.

mob/proc
walkto(var/mob/ref,var/atom/target,var/delay) //target could be obj, mob or turf
spawn() //will let proc finish, then start walking
while(get_dist(ref,target) > 1)
step_to(ref,target)
sleep(delay)
//do end walk stuff here inside spawn()