ID:764558
 
(See the best response by Albro1.)
Code:
   for(var/mob/rat/M in view())
walk_to(M,obj/cheese,1,5)


Problem description:
i am trying to walk a rat to its cheese. i am using the walk_to command but i am getting an error obj not defined.

when a player picks up the cheese, i don't want the rat to follow the player. how would i get this to work. thank you in advanced
You aren't telling it what obj/cheese is. You need to create a reference.

var/obj/cheese/c = locate(/obj/cheese)
for(var/mob/rat/M in view())
walk_to(M, c, 1, 5)
walk_to(M,locate(/obj/cheese),1,5)

the rat still walks to the cheese when the cheese is in the usr inventory
Best response
Then maybe you should do it the way I told you to. That way, you can check for things like that.

var/obj/cheese/c = locate(/obj/cheese)
if(istype(c.loc, /mob))
return // If the cheese is in a mob's contents, stop
for(var/mob/rat/M in view())
walk_to(M, c, 1, 5)
yes, that worked.
Great! I hope you learned something. Please vote up my answer so others can find the answer to their problems easier.