ID:179423
 
Why doesn't this work? I have a little game where you click on a mob and get a list of options for what you want them to do. One of the options is to go pick up something in view which gives you a list of the objects in view, you select from the list and the mob goes and gets it. But it doesnt work. Can someone help me out here? Heres the code:

The mob walks over to the objected but doesnt pick it up.

    var/obj/what = input("Get what?") as obj in view(src,5)
while(src in oview(what,5))
step_to(src,what,0)
sleep(5)
spawn() src.getobj(what)
return

proc/getobj(obj/O)
O.Move(src.contents)
oview() << "[src] picks up \a [O]."
Skrylan wrote:
Why doesn't this work? I have a little game where you click on a mob and get a list of options for what you want them to do. One of the options is to go pick up something in view which gives you a list of the objects in view, you select from the list and the mob goes and gets it. But it doesnt work. Can someone help me out here? Heres the code:

The mob walks over to the objected but doesnt pick it up.

    var/obj/what = input("Get what?") as obj in view(src,5)
> while(src in oview(what,5))
> step_to(src,what,0)
> sleep(5)
> spawn() src.getobj(what)
> return
>
> proc/getobj(obj/O)
> O.Move(src.contents)
> oview() << "[src] picks up \a [O]."


Ah, this is a difficult procedure.

It has a simpler solution than you'd expect, however.

Rather than checking to see if the person is in view of the object (which will almost always be true), instead check to see if the user's distance from the object is zero.

while(get_dist(src,what) > 0)
step_to(src,what,0)
sleep(5)
src.getobj(what)
return