ID:172215
 
i'm doing

usr.contents -= /obj/myobj


it compiles fine but when i actually use it(as a verb) i get a runtime error and the obj is not removed, the error says cannot remove from list
Don't know if this will help, but always use src, try src.
You are trying to remove a typepath from a list of obj instances. You want to locate an instance of that typepath and remove it.

var/obj/myobj/O = locate() in usr
if(O) del(O)

If you want to delete all /obj/myobj, you'll have to loop through contents like so:

for(var/obj/myobj/O in usr.contents)
del(O)
In response to Dragon of Ice
Dragon of Ice wrote:
Don't know if this will help,

Posting random advice to problems you don't understand will more likely hinder than help.

but always use src, try src.

"always use src" is bad advice. There are many cases when usr is the correct var, otherwise they would simply remove it from the language. Most cases of usr confusion require that information be passed as arguments into a proc, instead of relying on either usr or src. The trick is knowing when to use each method, not always using one of them.

Since this case involves a verb, usr is just fine (unless it is called as a proc elsewhere). If it is a mob verb using the default src setting (set src=usr), src would be just as good. Whichever var is used, the problem would remain.
usr.contents.Remove(/obj/myobj/)


Works for me....
In response to Sensi
It shouldn't.
In response to Shadowdarke
thanks A LOT for both the trigger and this code!