ID:165142
 
when i want to check for an item in usr.contents, i do this: for(var/obj/a in usr.contents) but what if i only want to get ONE? like for example if i want to delete ONE apple but i have two, writing this:
for(var/obj/apple/a in usr.contents) del a

would delete both. can anyone help?
Like you can use locate() to find a mob at a particular spot in the map, you can use it to find other stuff too. For example:
var/obj/sword/O = locate(/obj/sword) in player


(You might need the list itself, player.contents instead of player, but I'm not sure)
I'd try locate.

And what are you using this for? If you are using it for something such as obj/apple/verb/Eat(), I'd just put a del(src) in the verb.
In response to Jon88
Oh, so if i wrote:
var/obj/apple/a = locare(/obj/apple) in usr.contents
del a

then one of my apples would be deleted?
Yeah, that works perfectly, thanks again everyone.
In response to Bobthehobo
I am filling up a pot with flour, and i just thought that the player might have a pot with them that they want to keep empty as well as the one they are filling up.