ID:147981
 
I don't really want to make 25 different get verbs for all my contents, so I was thinking.. How would I just make one verb that picks up an object in a certain type path? Such as...

obj/item can be picked up, and the get verb would appear.

obj/household can not be picked up, and the get verb won't show up.

Here's what I have so far, but it isn't doing what I'd like it to do.
obj/verb/Get(obj/item/O in oview(1))
if(usr.contents.len <=14)
view() << "[usr] picks up an item."
del src
usr.contents += src
else
usr << "You already have the max. accessories."
return


Can anyone give me a hand? :P

-Camaro-
You need to Move() src into usr. Don't mess with the usr.contents list manually.
Just create the verb for the specific path type only.

obj/item/verb/Get()
The main problem you've got here is that you're calling del(src); you shouldn't be doing that here. After that's done, there's nothing to add to usr.contents, and the verb has already stopped by then anyway.

Lummox JR
In response to Jon88
And once you do that, you can do stuff with mob/Enter():
obj
item
verb
get()
if(Move(usr))
view() << "[usr] picks up [src]"

mob
var/capacity = 10
Enter(obj/item/I)
if(istype(I))
if(contents.len >= capacity)
src << "Your inventory is full!"
return 0
return ..()
Umm, Lummox is right. Just put del src after the usr.contents += src. That should work.
In response to The Conjuror
The Conjuror wrote:
Umm, Lummox is right. Just put del src after the usr.contents += src. That should work.

No, because then you're still deleting the object, and there's no reason to do that here. The del(src) doesn't belong in this code at all.

Lummox JR
In response to Lummox JR
Oh ok, thanks for the correction.
In response to Lummox JR
I combined all of your help(correct help), but there's still a problem.
obj/verb/Get(obj/items in oview(1))
if(usr.contents.len <=14)
view() << "[usr] picks up an item."
Move(src in usr)
else
usr << "You already have the max. accessories."
return


The verb still does not show up when I want it to. This code below does show up, and it DOES only pickup what I want it to. Except it's not being added to my contents.
mob/verb/Get(obj/items/t in oview(1))
if(usr.contents.len <=14)
view() << "[usr] picks up an item."
Move(t in usr.contents)
del t
else
usr << "You already have the max. accessories."
return


I've got part of it down, now all I need is it to show up in my contents.

-Camaro-
In response to Camaro
Camaro wrote:
The verb still does not show up when I want it to. This code below does show up, and it DOES only pickup what I want it to. Except it's not being added to my contents.
> 
> mob/verb/Get(obj/items/t in oview(1))
> if(usr.contents.len <=14)
> view() << "[usr] picks up an item."
> Move(t in usr.contents)
> del t
> else
> usr << "You already have the max. accessories."
> return
>
>
It might be because you are deleting the object right after you pick it up. :)
In response to Camaro
Camaro wrote:
Move(src in usr)

Wrong.

"src in usr" is interpreted as "if src is located in usr, this is 1; otherwise it's 0". If you want to move src into usr, then it's src.Move(usr)--or simply Move(usr).

Move(t in usr.contents)
del t

Same problem here; that should be t.Move(usr.contents).

And the del(t), like the del(src) you got rid of, doesn't belong there.

Lummox JR
In response to Lummox JR
Thank you, Lummox. I fixed what I needed :).

-Camaro-