ID:269939
 
For some reason, a stat meter overlay is causing my characters to go invisible, but are partly visible while moving..They start off visible, then after a couple updates to the meter and whatnot, they go invisi. I'm just wondering what could be the problem.
It could be for many reasons, like if you are incorrectly setting the icon or some other bajillion reasons. We don't know, so you'll have to paste how you did it for us to find out what you did wrong. Most likely that you're trying to set the player's icon state to change the stat meter's icon state.

~~> Unknown Person
In response to Unknown Person
Ok here goes:

obj
Meter
icon = 'meter.dmi'
icon_state = "30"
pixel_y = 10
width = 30

mob
proc
Update()
if(src.meter)
var/obj/O = src.meter
O.num = round((src.hp/src.maxhp)*O.width)
if(O.num >= O.width)
O.icon_state = "30"
src.overlays+=O
if(O.num <= 0)
O.icon_state = "0"
src.overlays+=O
if(O.num > 0 && O.num < O.width)
O.icon_state = "[O.num]"
src.overlays+=O

mob
Stat()
src.Update()


Its also called during battle...
In response to Mecha Destroyer JD
mob/proc/Update()
if(meter)
var/obj/O=src.meter
O.num=round((hp/maxhp)*O.width)
if(O.num >= O.width) O.icon_state="30"
if(O.num <= 0) O.icon_state="0"
if(O.num > 0 && O.num < O.width) O.icon_state="[O.num]"
overlays+=O


Other than the fact that you can shorten it a bit, what kind of variable is "meter"? And why are you calling Update() in Stat() when there appears to be no meter in Stat()?
In response to Artemio
He's calling that in Stat() because Stat() gets called (if defined) once every second. It'd be better to just call it when you need to (when the guy takes damage).

To Mecha, I suggest you use image objects for stat meters, because they end up being more flexible and don't stink and rot like overlays.

~~> Unknown Person
In response to Unknown Person
Unknown Person wrote:
He's calling that in Stat() because Stat() gets called (if defined) once every second. It'd be better to just call it when you need to (when the guy takes damage).

Uh, what?
> there appears to be no meter in Stat()?
In response to Artemio
As I said, he's calling Update() every time Stat() is called, which is once a second. It has nothing to do with a meter in a statpanel.

~~> Unknown Person
In response to Unknown Person
Sorry, but what do you mean by image object? I know I've heard it before, but I'm not exactly sure what you're talking about.
In response to Mecha Destroyer JD
The handy /image type which lets you easily attach icons and is easily editable.

I made a post on how you could do this here [which I oddly replied to you]: [link]

~~> Unknown Person