ID:2306888
 
(See the best response by Ter13.)
Code:
obj
energy_coat
layer=EFFECTS_LAYER + MOB_LAYER
alpha=150
density=0

New(mob/o)
if(!o)
return
appearance=o.appearance
icon_state=""
pixel_x=0
pixel_y=0
pixel_z=0
invisibility=2
icon-=rgb(255,255,255)
icon+=SKY_BLUE
alpha=150
Owner=o
o.overlays+=src


Problem description:
Wanted to create an effect where an overlay is invisible at most times during gameplay, however, under special conditions it can be seen by a player. The invisibility var seems to be reset or rendered ineffective when the overlay is added, resulting in the overlay being visible.
You should only be adding the overlay when it is needed. Invisibility doesn't work on overlays.
Not sure if its worth mentioning too, since you're using a mob as an overlay.

But, it seems if you make any changes to the mob before removing the overlay the same way it was added, it won't work.

I could be wrong though, its been a long time since I tried experimenting with that kind of situation.
In response to Ginseng
He's using the mob as a reference for what the overlay should look like.

But, it seems if you make any changes to the mob before removing the overlay the same way it was added, it won't work.

I could be wrong though, its been a long time since I tried experimenting with that kind of situation.

This is true when a reference to a modified overlay/underlay is not kept. A fine point made the OP may want to consider.
Ah, so i guess probably images would be my next best shot? @Ter13

I'm not using a mob as an overlay, and I know that overlays are appearances rather than the added datum, so any alteration will cause you to lose the reference to the previous appearance. But thanks for answering :D
@Ginseng
Best response
@DimensionalRift

512 features a new kind of overlay called vis_contents. It's like an /image that's visible to everyone.

Give it a shot. But again, you should only be adding the overlay when you need it, so given your use-case, you don't need the added overhead of vis_contents.
I'll look into it regardless, for possible future needs