ID:1122014
 
(See the best response by Super Saiyan X.)
Hey everyone, this is a simple issue. I have a datum defined like so:

bar
overlay
layer=FLOAT_LAYER
hide() owner:overlays -= src
show() owner:overlays += src
upd() // called in order to update the icon state based on a percentage
.=..()
hide()
show()


utilized like so:

mob
var/bar/overlay/basic/my_bar
verb/test()
if(!my_bar)
my_bar = new
my_bar.owner=src
// do stuff with values and such
my_bar.upd()


The issue here is, every time I update the icon state, instead of the icon changing entirely, a new overlay with the new icon state is drawn over the current one. The only solution I know at the moment is wiping the overlays list, which is not good as I have other overlays and having to re-add every overlay each update would be stupid. Is there something I'm missing here?
Best response
for the sake of having a resolved topic;
I helped Meta solve the issue.
He was changing a variable of the /bar/overlay object before he removed it.
The way the overlays list works, you must remove an object with the same exact variables as the object you initially put in.

Solution: Remove the object from the list, then change the variables, then add it again.