ID:140080
 
Code:
                if(choice=="Take")
var/item
for(item as obj in view())
if(item in view())
walk_towards(src, item, 1)


Problem description:

I am trying to get it so that you can choose from a list of items in sight, but it's not working. How can I get it to do what I need it to do?

HOLY SWEET MOTHER OF GOD, I got it working. Nevermind. Thanks for at least taking the time to read this.
For future note, you can condense that to the following:
if(choice=="Take")  //  Use switch() if there's too many if(choice==...
for(var/obj/item in oview(src))
walk_towards(src, item, 1)


In var/path/V, the path (/obj) here specifies what type to look for. The reason for using oview() is that there's no point for walking to an object over on top.

Now note there's a problem here and that is that it resets its direction for each item looped. To make it go to one item at a time:
var/obj/item = locate() in over(src)
if(item) walk_...


If no argument is define in the locate(), it takes the path defined in the variable, which is /obj in this case.
In response to GhostAnime
ALright, well now I'm having trouble with making a object exit. I've already used src.contents+=toTake , but the problem is now I can't figure out how to create it and remove it from the inventory.
In response to CodeWeasel22
Why don't you just make it Move()?
obj.Move(mob)  //  move an /obj in to a /mob's contents
obj.Move(mob.loc) // Move an /obj to the turf that the /mob is on
In response to GhostAnime
Problem is I want it to be tailored more generically, like if such an item is picked up it is automatically picked up. So the too generic obj. thing won't work.
In response to CodeWeasel22
You're going to need to give a description of what you want that actually makes sense.