ID:155958
 
I've come to notice that upon making a Get verb for picking up items off the ground it also lets me pick other objects like energy beams and other stuff that it shouldn't. So how exactly do I stop it from doing this
Define a list for un-pickable items and add all name of items you want un-pickable. Then use Find() proc on the Get() verb, that if the name exists in un-pickable items. Don't let usr pick it.
In response to Hashir
how exactly do i code that cause im not sure if i would go

list.Find(Elem,Start=1,End=0)


would i put the Elem as the name of like whatever you cant grab?Then how would i do the rest like if it finds it as a if statement or w/e
In response to Mastergamerx
if(Unpickableitems.Find(pathofobj))


It might be weird bcoz i cant remember find proc codes. But don't worry give it a try.
It's mostly a matter of object hierarchy.

Things that can be picked up can be sub-types of say ...

/obj/item

Then put a pickup() verb on /obj/item, not the player.
In response to Stephen001
In reference to what Stephen001 is saying, you could just use the object type to determine if the item was able to be picked up. I don't know how you structured your code tree, but if you would put all the items that can be picked up under /obj/item like Stephen said, you could just do this.
verb
Get()
set src in view(1)
if(src.type == /obj/item)
src.Move(locate(usr.contents))
usr << "You pick up the [src]."
else
usr << "You cannot pick up this item!"

I didn't check if this compiles, but it should work just fine.
In response to Brizzel987
Actually, I think he was suggesting an even simpler approach:

Simply define the verb under /obj/item, and it won't even be available for other objects.

Also, just for future reference, you should be wary of comparing datum types directly with "==", as it won't take child classes into account (for example, in your code, /obj/item/sword will give the "You cannot pick up this item!" message). Instead, you should use istype().
In response to DarkProtest
ahh yes, you are right about the "==" because if that were used, you would have to specify every single item, which is a pain and totally unneeded. Thank you for calling that to my attention lol
In response to Hashir
Why not just define a proc such as "GetObj()" that has your Get code.
instead of:
verb
Get()
set src in view(1)
if(src.type == /obj/item)
src.Move(locate(usr.contents))
usr << "You pick up the [src]."
else
usr << "You cannot pick up this item!"

use
proc
Get()
set src in view(1)
if(src.type == /obj/item)
src.Move(locate(usr.contents))
usr << "You pick up the [src]."
else
usr << "You cannot pick up this item!"


then whenever you have an object you want to pick up, such as a sword, you would just call the proc. :\

I'm new, but I think this would work. If not, please correct me so I can learn ^^:
In response to Brizzel987
if you're going with this approach, couldn't you also list the other types like so?
verb
Get()
set src in view(1)
if(src.type == /obj/item || /obj/item2 || /obj/item3)
src.Move(locate(usr.contents))
usr << "You pick up the [src]."
else
usr << "You cannot pick up this item!"
In response to Nacht Silence
No. The || operator does not work like that.
That would be the equivalent of saying
If src.type is /obj/item OR /obj/item2(non-null, evaluates to TRUE) OR TRUE. This means it will always work no matter what.

What you'd want in this case is(other than organizing your paths so you could use istype()) to use the in operator.
As Stephen001 said, this would probably be your best way around.
Simply class all objects under a certain parent(in this case is /obj/item). The 'Get' verb will pick up any objects under that parent type and ignore others.

obj/item
test_obj
icon='Icons/_Items.dmi'
icon_state="testobj"
verb
Get()
set src in orange(1)
range(usr)<<"[usr] picked up \an [src]!"
usr.contents+=src


This is definitely better than the idea of using a list, because the list would eventually get to large, cluttered, and with this you don't have to worry about adding objects to a list or anything like that.
In response to Nacht Silence
Your code is fine but instead of using locate, it's much simpler to use this:

mob/verb/Get()
set src in usr.loc
loc = usr
usr << "You Get [src]."



And also you should use set src in usr.loc, so the object is only pickable, if the user is over it.


And btw, you are using usr in procs. Never use usr is procs. Define a variable for the user and item, but never use usr in procs.