I'm working on a new project to get back into the swing of things and that means I get to learn how skins work once and for all. So I've been going over LummoxJR's Makind Skins in Byond 4.0 and I had a few questions about some of the code in the Lesson 2 project files.
Mostly I was curious if one of you would be so kind as to look over this and let me know if I am understanding everything that is happening here correctly.
Block in question
if(!O || !O.slot) return
if(equipment && equipment[O.slot])
if(equipment && equipment[O.slot]) return // unequip failed
if(!equipment) equipment = new
equipment[O.slot] = O
The same block fully expanded with comments containing my thoughts on what is going on.
if(!O || !O.slot) // If there is no object or the object does not have a slot,
return // return and end proc.
if(equipment && equipment[O.slot]) // If the mob using equip() has a list "equipment" and something occupying the
// objects' slot in the mob's equipment list (has something equiped in the slot
// of the item attempting to equip.)
Unequip(equipment[O.slot]) // Then we will call unequip in an attempt to remove the previously equiped object
// in the slot in question.
if(equipment && equipment[O.slot]) // Redundancy check to see if the unequip was sucessful.
return // If unequip was unsucessful return and end proc.
if(!equipment) // If the mob does not have an equipment list,
equipment = new // create a new equipment list.
equipment[O.slot] = O // Set the equipment list key for the slot in question to the object in question.
UpdateInventory() // Call UpdateInventory() updating the inventory grid.
UpdateEquipment() // Call UpdateEquipment() updating the equipment grid.
I think I have a pretty firm grasp on this, I would just like a little confirmation after being mostly inactive for a year or so. Thank you for your time.