ID:139044
 
Code:
        Anvil
density=1
icon_state="anvil"

Click()
var/making = input("What object do you wish to create?") in list ("Copper Wire","Digger Control")
switch(making)

if("Copper Wire")
var/S = locate(/obj/Ore/Copper_Ore) in usr.contents
if(S)
var/obj/Product/Copper_Wire/C = new
C.Move(usr)
del(C)

if("Digger Control")
var/O = locate(/obj/Sheet/Iron) in usr.contents
var/L = locate(/obj/Sheet/Iron) in usr.contents
var/T = locate(/obj/Product/Copper_Wire) in usr.contents
if(O&&T&&L)
var/mob/Static/Digger_Control/R = new
R.Move(usr.loc)
del(O)
del(L)
del(T)


Problem description:
I've had this weird problem for a while now, and I can't see what the problem is by myself. :/ Basically, whenever I pick "Copper Wire" from the list, it does nothing else. I don't lose the copper ore, and I don't get the wire.

The path should be with the variable definition and locate's arguments should be null.

var/obj/item/apple = locate() in usr.contents

OR

if( usr.contents.Find ( /obj/item/apple ) )
In response to Neimo
Yeah, but I have to delete the object afterwards, too. I'm not a really experienced coder, care to explain how I should put this into the complete verb? :P
In response to Shaoni
You would either delete it or remove it from the contents of the user.

del apple

OR

usr.contents.Remove( /obj/item/apple )
In response to Neimo
I got it to work, thanks! ^^
In response to Shaoni
Just keep in mind Shaoni if you intend to use a stacking system later on the simple "delete the object" method will no longer be valid.

Instead you will need to search for the item, edit its value "amount" check that its amount isnt going to be 0 afterwards if so then delete it. And so on.

Just keep that in mind when venturing further into crafting and item systems

~Midget
In response to Midgetbuster
Agreed... though you can do a little trick using Del() to remove a stacked amount instead of the whole object:
Item
Apple
Del() // When the object is being deleted via del
src.amount -= 1
if(src.amount <= 0) // No more of that item is left
return..() // Call the parent procedure, which will remove the item
else
src.Update() // Updating the amount of your item via editing suffix, outputting to a grid, etc.
// Note the lack of ..() here. When you call ..(), it WILL delete the object