When the function runs, it looks at what variable name I have supplied, and it finds that variable on the mob and uses that value.
I'm doing this because the mob has several variables on him that are references to objects being carried.
However, using this code:
Equip(mob/Human/Player/Wearer, obj/Item, obj/Slot, var/Layer){
if(Slot == null){
Drop(Wearer);
Item.Move(Wearer);
Item.suffix = "(Equipped)";
Slot = Item;
Wearer.overlays += image(Slot.icon, icon_state = "Equipped", layer=Layer);
}
}
I can't do something like this
Equip(usr, Item, usr.BodySlot, Body_Layer);
It just doesn't work. Modifying the code however to this:
Equip(mob/Human/Player/Wearer, obj/Item, var/Layer){
if(Wearer.BodySlot == null){
Drop(Wearer);
Item.Move(Wearer);
Item.suffix = "(Equipped)";
Wearer.BodySlot = Item;
Wearer.overlays += image(Wearer.BodySlot.icon, icon_state = "Equipped", layer=Layer);
}
}
will make it work,
but I'm not going to write a special equip function for every damn equipment slot, where the only differences would be the words like BodySlot, HeadSlot, ArmSlot, etc...
advice
This will check to see if the Wearer has a variable called "BodySlot", and if it does, it will assign the item to that variable.