ID:149902
 
Most of this works fine, till you try to unequip and already unequiped item. Also it then allows you to drop an item equiped. I need some help in finding out where the hole in the loop is??? Problems begin when you try to equip or unequip 2 items.

verb
Equip()
set src in usr
var/mob/pc/M = usr
if(M.equiped == 0)
pick = 1
M.equiped = 1
suffix+="Equiped"
usr << "You have equiped the pick."
else if(M.equiped == 1)
usr << "You already have something equiped!"
return
UnEquip()
set src in usr.contents
var/mob/pc/M = usr
if(M.equiped == 0)
usr << "You have nothing equiped!"
else
pick = 0
M.equiped = 0
suffix=null
usr << "You have unequiped the pick."
Drop()
var/mob/pc/M = usr
if(M.equiped == 1)
usr << "You must unequip the pick to drop it."
else if(M.equiped == 0)
usr << "You drop [src]"
Move(usr.loc)
LordJR wrote:
Most of this works fine, till you try to unequip and already unequiped item. Also it then allows you to drop an item equiped. I need some help in finding out where the hole in the loop is??? Problems begin when you try to equip or unequip 2 items.

I had a little trouble following your code through, but I think as a rule you should avoid using boolean yes/no values to say whether something is equipped or not. Instead, use a different var like mob/var/obj/equipment to point to the equipped item. This provides the same information in a cleaner way. (Also, "equipped" is spelled with two P's.)

For example, when you equip an item:
verb
Equip()
set src in usr
var/mob/M=usr
if(M.equipment)
if(src==M.equipment) M << "[src] is already equipped."
else M << "You must unequip [M.equipment] before you can equip [src]."
return
M.equipment=src
suffix="(equipped)"

If you can equip more than one of a particular item type, it's probably best to use a list.

Lummox JR