ID:799410
 
(See the best response by DarkCampainger.)
Code:
obj
Weapon
var
dmg
weight
value
poison
enchant
equipped
mtype
distance
verb
EquipUnequip(var/mob/M)
set src in usr
set name = "Equip/Unequip"
M.wdmg = src.dmg
M.Weapon = src
M.WeaponType = src.mtype
DblClick()
if(istype(src))
if(get_dist(usr,src) <= 1)
usr << "<b>You pick up [src].</b>"
new src(usr)
del(src)
else
usr << "object too far!"
else
return


Problem description:
When I double click an object, it gives me the following runtime error:

runtime error: Cannot create objects of type /obj/Weapon/Iron_Axe.
proc name: DblClick (/obj/Weapon/DblClick)
usr: BeignetLover (/mob)
src: Iron Axe (/obj/Weapon/Iron_Axe)
call stack:


Best response
You want new src.type(usr). However, instead of recreating and deleting the item, it usually makes more sense to move it with src.Move(usr) or src.loc = usr.

Also, that if(istype(src)) is nonsensical, unless you're reassigning src earlier in that process.

Also, your EquipUnequip() verb should be using usr for the player instead of the /mob/M argument--otherwise they can equip it to someone else!
I chose the istype(), because I have other instances of obj/Weapon. That way I don't have to code the vars all over again. But thanks for the help :)