ID:149779
 
i have a problem with my code. the pc in my game is supposed to use the verb Take which checks the item at the usr's feet to see if it is the unique item, and if it is then the usr picks it up, and if its not the usr gets the message "you cant take the [O]", but he wont take it no matter what. ive tried fixing my problem a few different ways. my code for it looks like this:


mob/verb/Take(obj/O as obj in view(0))
if(O==/obj/item/uniqueitem)
del(O)
usr.specialitem=1
usr<<"You take the [O]."
else if(O==/obj/item/uniqueitem2)
del(O)
usr.specialitem=2
usr<<"You take the [O]."
else
usr<<"You cannot take the [O]."

at first i used if(O=="uniqueitem") but it gave me a runtime error that said O.name was null. so i gave the unique items a name and told it to do if(O.name=="uniqueitem") so that it wouldnt be null, but it still didnt work, so i tried using its path instead, then i didnt get any runtime errors but i always got the message "you cant take [O]" and the usr doesnt take it. if u can tell me what i am doing wrong it would be great.
Loduwijk wrote:
if(O==/obj/item/uniqueitem)

Your problem is right in there. You need to use istype() to identify the type of object.

Lummox JR