ID:146583
 
Code:
obj/var/equipable = 0
obj/var/occupied = 0
obj // needs to be tested
verb
equip()
set src in usr.contents
while(src.occupied == 1)
usr << "You can not equip this item."
break
while(!src.equipable)
usr << "You can not equip this item."
break
while(src.occupied == 0 && src.equipable)
if(src.equip_types == "Weapon")
occupied = 1
usr.added_on_attack += src.weapon_attack
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"
if(src.equip_types == "Armor")
usr.added_on_defense += src.armor_defense
occupied = 1
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"


Problem description:Once the item is equiped once, it's occupied variable is supposed to == 1. And the next time someone trys to equip an item of the same type (meaning the variable occupied == 1), It is supposed to say, "You already have an item equiped.". Why is it not working?
DragonMasterGod wrote:
Once the item is equiped once, it's occupied variable is supposed to == 1. And the next time someone trys to equip an item of the same type (meaning the variable occupied == 1), It is supposed to say, "You already have an item equiped.". Why is it not working?

It's not working because you're using the wrong var in the wrong place and asking it the wrong thing.

In this case, src.occupied belongs to the object, not to the mob. All it's doing is ensuring you can't equip the same obj again, but as far as the mob's concerned, anything is fair game. (Incidentally, the word "occupied" makes zero sense here. A room is something you occupy, not a sword or a hat.)

The reason you made this mistake is that you didn't take the advice Wizkidd already gave you in [link] when he pointed you toward a working equipment system.

Right now you've got a system in which only the obj knows it's equipped, but the mob doesn't know jack. The mob needs to know which item if any is equipped, and if it knows that then there's no need for an obj "equipped" var. An obj can always find out if it's equipped by seeing if 1) its loc is a mob, and 2) that mob has that specific item equipped. It's much much more useful to know which item the mob has equipped, not to set a yes/no var for each obj.

And you're still doing the ==1 and ==0 thing too. It's like you didn't read Wizkidd's post at all.

Lummox JR