ID:148919
 
<dm>I have a problem with adding and removing overlays. I have a parent object type with several child types. The parent has the basic functionality:

<dm>
parent
parent_type = /obj
var/p_layer
proc/Add()
layer = p_layer
usr.overlays += src
verbs -= /test_verbs/Add_Overlay
verbs += /test_verbs/Remove_Overlay

proc/Rem()
usr.overlays -= src
verbs += /test_verbs/Add_Overlay
verbs -= /test_verbs/Remove_Overlay


Every item made from the parent obj has the Add and Rem procs. However, each of the children items are customized as follows:


child
icon = 'child.dmi'
p_layer = CHILD_LAYER
Add()
..()
if(!usr.child)
usr.child = src

Rem()
..()
usr.child = null


This allows me to modify where the object goes on the player. The Add() proc works fine, it adds the overlay and sets the usr.child to src. The problem comes when I try to remove the child from the player. It sets the usr.child to null, like it's supposed to, and modifies the verbs, but it will not remove the overlay. Oh, the verbs are simple calls to the procs, nothing else.

Can anyone see what I'm doing wrong?

[EDIT]
I tried something and found that if I move the Rem() proc to the lowest child, it works. But only if it's the final child of that type. I'd still like to know why it doesn't work through inheritance, because it would make my life a LOT easier.
[/EDIT]

-Sapphiremagus
I have had similar problems with my first game...I don't know what I did to fix it because it works fine now but you might have more luck if, instead of adding the object as an overlay, add image(src.icon,src.icon_state) then subtract the same; i don't know if it will work better for certain because i don't know what all else you may be doing to the object inbetween but its worth a shot.