//this comes after my proc for a new game
usr.overlays+=new/obj/meter/healthbar
usr.overlays+=new/obj/meter/manabar
usr.updatebar()
obj
var/width
meter
healthbar
name=""
icon='bars.dmi'
icon_state="0"
pixel_y=27
layer=MOB_LAYER+10
width=28
var/num=0
manabar
name=""
icon='bars2.dmi'
icon_state="0"
pixel_y=22
layer=MOB_LAYER+10
width=28
var/num=0
mob
proc/updatebar()
world<<"TEST"
for(var/obj/meter/healthbar/o in src.overlays)
world<<"TEST 2"
o.num=(src.HP/src.MAXHP)*o.width
o.icon_state = "[round(o.num)]"
src.updatebar()
if(o.num < 0)
o.num = 0
else if(o.num > o.width)
o.num = o.width
Problem description:
I'm trying to make it so when the player logs in they get a health and magic bar.......and this bar goes up or down depending on their health or magic left. I'm horrible with overlays and I can't figure out what I need to do above. The above gets past the first "TEST" but not the 2nd one. I've looked and looked at tutorials, but they dont help much. So far it only displays the empty health/magic bar. I want them both to display over the usr's head. I'm asumming I messed up somewhere in the defining....
Alternatively, you can use the better and more flexible alternative, image objects. That way, you can set the image object's location onto your mob, and just update the image's icon_state whenever your health or mana bar needs to be updated. You also have the flexibility of choosing who can look at it.