ID:146590
 
Code:
obj/var/equipable = 0
var/occupied = 0
obj // needs to be tested
verb
equip()
set src in usr.contents
while(occupied == 0)
if(src.equipable == 1)
if(src.equip_types == "Weapon")
usr.strength += src.strength
added_on_attack = src.strength
occupied = 1
src.suffix = "Equip"
if(src.equip_types == "Armor")
usr.defense += src.defense
added_on_defense = src.defense
occupied = 1
src.suffix = "Equip"
if(src.equipable == 0)
usr << "You can not equip this item."
return
while(occupied == 1)
usr << "You already have an item equiped."
return
remove()
set src in usr.contents
while(occupied == 1)
usr << "You remove [src.name]."
usr.strength -= src.strength
added_on_attack = 0
usr.defense -= src.defense
added_on_defense = 0
occupied = 0
src.suffix = ""
while(occupied == 0)
usr << "You have nothing on to remove."
return


Problem description:This code has not been tested yet, but, I'm wondering if it will work. Recognize the two types "Weapon" and "Armor".
First, you should be saying if(myVar) and if(!myVar) instead of if(myVar == 1) and if(myVar == 0), respectively.

You see, in DM, null, 0, and "" are considered to be different values. While checking for if(myVar == 0) only checks for a value of 0, checking for if(!myVar) checks for all three.

if(!myVar)

is equivalent to:

if(myVar == 0 || myVar == null || myVar == "")


Now, your equipment system has a design flaw in that you could do it in a much easier way:

Instead of using boolean variables (variables that are either equal to 1 or to 0 (ie: density)), you could instead have a system where a player's "weapon" variable is always equal to the actual weapon object that the player has equipped! It makes things much easier!

I recommend taking a look at hub://wizkidd0123.equipmentdemo.
In response to Wizkidd0123
O.O Thanks Wizkid. You're absolutely right, it really does help.