ID:2344749
 
Code: So apparently BYOND lacks the ability to have a computer mob walk towards you until a desired location is met, then end its walking protocol.
With that being said, here is the code if you are interested in that particular function. Good luck!

mob
computer_001
icon='mobcolor.dmi'
density=1
New()
src.red=rand(0,255);src.green=rand(0,255);src.blue=rand(0,255)
src.icon+=rgb(src.red,src.green,src.blue)
overlays+='moboutline.dmi';overlays+='mobeyes.dmi'
createcharacter(src)
sleep(30)
locatemob()
proc
locatemob()
var{xaxis;yaxis}
do
for(var/mob/M in oview(8))
xaxis=x-M.x
yaxis=y-M.y
if(xaxis>1 || xaxis<-1 || yaxis>1 || yaxis<-1)
step_to(src,M)
sleep(5)
while(xaxis>1 || xaxis<-1 || yaxis>1 || yaxis<-1)


Problem description: There is no problem! Anymore! If anyone would like their computer mob to walk up close to player and stop, here's the code! I tested multiple times. Everything should be in working order. Good luck!

Um... What? This is what walk() in the F1 reference of Dream Maker says.

"Move Ref in the direction Dir continuously. Each step will be preceded by Lag time of inactivity.

A call to a walking function aborts any previous walking function called on Ref. To halt walking, call walk(Ref,0).

This function returns immediately, but continues to process in the background."
I don't appreciate being corrected when someone's already helped me.. and all im doing is paying it forward by giving out free code. I was trying walk_to.. Unfortunately its continuous as well, but no need. Problem solved! Hope it may help anyone else with this problem. Cheers!
And I don't appreciate people spreading misinformation. It becomes a detriment to a whole community as opposed to just one person. Both step() and walk() have their ups and downs, but stopping them is very trivial.
Says the one degrading my work. Saying that im detriment to the whole community is indeed very wrong of you. Considering this post is to help others. If nobody shared code.. BYOND wouldn't even be half the community it is today.
Could you stop deleting your threads? See PSA: Please don't delete resolved threads, it's a pinned thread in this forum. You posted at least 2 threads before this one on this same problem, and instead of simply replying to the first one, you deleted all of them.

Also, there's a built-in function for getting the same distance between two objects that you'd pass as walk_to()'s minimum distance argument: get_dist(). So, instead of your do-while with all the math, you can do this:
var 
mob/target = locate() in oview(8, src) // You're probably gonna need a better way of searching for a target.
const
min_distance = 1 // Stops when distance reaches this point or lower.
max_distance = 1#INF // Stops when distance reaches this point or higher.
step_interval = 5 // Time between steps.
while(target && target.z == z && (get_dist(src, target) in min_distance to max_distance))
step_to(src, target)
// If using tile gliding, set glide_size here.
sleep step_interval

Or you can simplify your math a bit using abs() (which gets you to the same result as get_dist()):
// ...
var distance = max(abs(target.x - x), abs(target.y - y))
if(distance > min_distance)
step_to(src, target)
// etc.
Cool way of writing it bro! Ya I'm from BYOND like.. 13 years ago.. Like Dragon Ball Gekisin and such lol So forgive me if my way of writing is old school. I haven't really touched programming since. Just a little bit of web designing.

PS: I posted a problem about my gamepad compatibility.. If ya both would be so sweet as to take a look at my problem and potentially help solve it! Thanks!
In response to Kaiochao
Kaiochao wrote:
Could you stop deleting your threads? See PSA: Please don't delete resolved threads, it's a pinned thread in this forum. You posted at least 2 threads before this one on this same problem, and instead of simply replying to the first one, you deleted all of them.

Unlikely since he did the same thing with his "gamepad issue" as well. I saw that post a day or two ago and now he's deleted it and recreated it just to "bump" it. If no one's responding to your forum posts, there's a working Discord you can join to get a more immediate response since he's clearly of the impatient type.
Saying that im detriment to the whole community...

I specifically said spreading misinformation is a detriment to a whole community. But hey, blowing things out of proportion is what people like to do when they play the victim.

Considering this post is to help others. If nobody shared code.. BYOND wouldn't even be half the community it is today.

http://www.byond.com/forum/?post=35017
Enjoy. Nadrew's already put out a useful little tutorial on how to use the walk/step procs, alongside some other basic built-in procs DM is so kind to provide us all. He even mentions that great walk(ref,0) tidbit I mentioned earlier from the reference. Oh, and by the way - that just so happens to be where your little "contribution to the BYOND community" belongs: in the Tutorials & Snippets forum. But that's just me being nitpicky at this point. I won't even mention the tons of AI demos/libraries in the development part of the site (which is what this is - AI programming).