ID:161345
 
verb/Equip(mob/M)
if(slot in M.equipped)
M << "[src] is unequipped."
suffix = ""
M.equipped -= slot
else
M.equipped += slot
M << "[src] is equipped."
suffix = "Equipped"



Well, I want to make sure that they can't equip more then one weapon. If they find that slot in the M.equipped is tells them to unequip the weapon, but I want to make sure I can equip the weapon still. I figure someone can fix it.. I know the line up is wrong...
verb/Equip(mob/M)
if(src in M.equipped)
M << "[src] is unequipped."
suffix = ""
M.equipped -= src
else
var/equip = 0
for(var/E in M.equipped)
equip = 1
break
if(equip)
M.equipped += src
M << "[src] is equipped."
suffix = "Equipped"
You're not storing enough information in your equipped list. All you have is information that SOMETHING is equipped there, but you aren't keeping track of WHAT it is. The easiest thing you can do at this point is to use an associative list, like so:

item
parent_type = /obj
//get and drop verbs would go here
equippable
var/slot
//handles the effects of equipping and unequipping (stat mods, etc)
proc/equip(var/mob/M)
proc/unequip(var/mob/M)

verb/Equip()
//if they have an available slot for this item
if(slot in usr.equipped)
//get the item equipped there
var/item/equippable/E = usr.equipped[slot]
//if there's nothing there, then just equip this item
if(!E)
usr.equipped[slot] = src
src.equip(usr)
//if this item is already equipped
else if(E == src)
//unequip this item
usr.equipped[slot] = null
src.unequip(usr)
//if there's some other item already there
else
//unequip it
E.unequip(usr)
usr.equipped[slot] = src
src.equip(usr)


For this to work, the players will need to start with a list consisting of the slots that they can equip. So, for example, you'd need:

mob
var/list/equipped = list("lhand", "rhand", "head", "body")
In response to Garthor
Ok, you just confused the hell out of me, but I know that is what I want..
In response to Lundex
Basically, an associative list means you've got one list that has keys and values. You can get the value associated with a key by list[key]. So, for example, to get the value associated with "head", you'd use list["head"]. This is useful, because you can call keys "slots", and values "equipment", and it fits the system you need.
In response to Garthor
Hmm, I think eventually I'll learn what the hell I'm suppose to learn...
In response to Lundex
In response to Garthor
Hmm, thanks alot. It really helped me out. I think I understand it now.