ID:145438
 
Code:
Unequip(mob/M in view(0))
M.overlays.Cut(src)
src.suffix = ""
src.location = ""


Problem description:
For soem reason, this little bit of code seems to remove all overlays from the mob in question. Can anyone tell me why? I've tried using straight out M.overlays -= src and also a for loop through the overlays list to check if it's there and remove it but both have done nothing. Any help at all in this would be grand. Thanks.

- GunRunner

GunRunner wrote:
Code:
> Unequip(mob/M in view(0))
> M.overlays.Cut(src)
> src.suffix = ""
> src.location = ""
>

Problem description:
For soem reason, this little bit of code seems to remove all overlays from the mob in question. Can anyone tell me why? I've tried using straight out M.overlays -= src and also a for loop through the overlays list to check if it's there and remove it but both have done nothing. Any help at all in this would be grand. Thanks.

- GunRunner


Well first off, why do you have mob/M in view(0)? Unequip should be under your object as a verb. If you want to keep the same design, you could do this.

obj/Armor/verb/Unequip()
usr.overlays-=src
src.suffix=""
src.location=""


usr is the person who uses the verb, src is the object that the verb belongs to. In order for this to work properly, you will have to do the exact opposite for equip.

obj/Armor/verb/Equip()
src.location="?"
src.suffix="Equipped"
usr.overlays+=src


The best way would be like this.

obj/Armor
icon='Armor.dmi'
Helmet
icon_state="Helmet"
verb
Equip()
usr.overlays+=icon('Armor.dmi',"[src.icon_state]")
src.suffix="Equipped"
Unequip()
usr.overlays-=icon('Armor.dmi',"[src.icon_state]")
src.suffix=""
In response to Aaiko
Thansk for that, I'll try it out.

- GunRunner