ID:144140
 
Code:
mob
verb
Dash()
var/M
M = /mob/player
if(M in oview(5))
step_towards(src,M)
else
usr << "No one is in sight"


Problem description:

Ok, i need this to dash(walk) to the player but it does not work i think its getting the player(itself) and the other player(the player to walk to) mixed up any ideas how to make it tell itself from the other player?
You aren't specifying WHICH /mob/player to walk to.., what I mean is, It's like saying: if Human in Sight: Step to Human

while you should say: if Human in Sight: Step to Human named Bob


... I just hope you understood my awkward example.
What's going on is your finding ANYTHING in the world's contents and typecasting it as a player.
In response to Kazekage
With that in mind, you should make sure it removes the player from the list you make.
for(var/mob/player/P in src.view())
if(P != src)
list += P

Or something like that.
In response to Polantaris
mob/verb/Dash(mob/M in oview(5))
step_towards(usr,M)


Simple, no?
In response to Pyro_dragons
That works as well.

I try to avoid creating variables from verb declaration because you cannot add anything to the input that you want, and if I want to make it into a proc later that doesnt work anymore.

Just my opinion.
In response to Polantaris
Thanks guys that helped
In response to Pyro_dragons
mob/verb/Dash()
for(var/mob/player/M in oview(usr,5))
step_towards(usr,M)
return


I don't see you trying to define any specific selection to decide which mobile in oview(usr,5) to walk to, so this is my code to go along with that idea.

However, if you'd like to decide which mobile to dash to, pyro_dragons' example is probably better.

(I added a return after so it wouldn't walk towards every single mobile within 5 squares of the user. I'm sure you don't want that.)
In response to Keeth
Keeth wrote:
(I added a return after so it wouldn't walk towards every single mobile within 5 squares of the user. I'm sure you don't want that.)

Bad usage on his part, yes, but so is looping threw all/X objects and break/return-ing after the first one. Instead, just use locate() with the type path which will return you the first object of that type found (if there're more than one).
In response to Kaioken
Also if you want to avoid spamming of the runtimes, be sure to do a check to see if there Even is a mob there before sending them to them

IE if(M)

just a suggestion, nothing to take seriously i guess.