ID:158950
 
I know this is probably a noob question but I need help with overlays. I tried to search the How-To forum and none of the search results really helped so I decided to ask for myself. What I need is a code that I can add to my current codes and will add overlays when I equip something and remove the overlay when I unequip it. Here are my current procs and verbs for equip and unequip.

mob
proc
Equip(obj/O)
if(!O || !O.slot) return
if(equipment && equipment[O.slot])
Unequip(equipment[O.slot])
if(equipment && equipment[O.slot]) return // unequip failed
if(!equipment) equipment = new
equipment[O.slot] = O
UpdateInventory()
UpdateEquipment()

Unequip(obj/O)
if(!O || !O.slot) return
if(!equipment || equipment[O.slot]!=O) return // failed
equipment -= O.slot
if(!equipment.len) equipment = null // reclaim the list
UpdateInventory()
UpdateEquipment()
obj
verb
Equip()
if(slot) usr.Equip(src)

Unequip()
if(slot) usr.Unequip(src)


I don't know if this really matters but I'll be using icon states for this instead of individual icon files. For example the icon file would be items.dmi and the actual item I want to equip would be in that icon file with the name shirt.
Safest method.

Add the icon or object path to a list, named Overlays (notice the capitalization) or anything. Then when you add to it, it clears overlays and adds everything from that list to your overlays. And whenever you remove anything, you remove it from that list, remove all overlays again and re-apply from the list.

mob
var/list/Overlays=new
AddOverlay(o)
Overlays+=o
overlays=null
overlays=Overlays
RemoveOverlay(o)
if(Overlays.Find(o)) Overlays.Remove(o)
overlays=null
overlays=Overlays


This WAS covered quite a few times, though.