ID:149856
 
Ok this is my Dig code, but I'm having a runtime error, I what there to be a chance that the item in use can break. And if that happens it takes the item in use away from the user.


My Code:

Dig()
if(!istype(usr,/mob/pc)) return //Silly npc, verbs are for players *CHECK*
var/mob/pc/M = usr
var/R = (rand(1,20))
if(R == 17)
M.hands = "hands"
M.verbs-=/mob/hidden/verb/Dig
usr.contents.Remove(/obj/items/clay_tool in usr.contents)
usr << "The clay tool you were using broke!"
return
usr << "You dig for clay."


My Runtime error:

runtime error: cannot remove from list
proc name: Dig (/mob/hidden/verb/Dig)
usr: LJR (/mob/pc/male)
src: LJR (/mob/pc/male)
call stack:
LJR (/mob/pc/male): Dig()



LJR
You have to locate a particular instance of the the tool, then remove it.

Replace
usr.contents.Remove(/obj/items/clay_tool in usr.contents)

with
var/obj/items/clay_tool/tool
for(tool in usr.contents) // most people use locate() for this...
break
if(tool) del(tool)

or the locate() method (I'm not sure this is right. I only use locate() for turfs in my own code.)
var/obj/items/clay_tool/tool = locate() in usr
if(tool) del(tool)
In response to Shadowdarke
Thanks the later one worked for me!! :D

I'm making headway here...

LJR