ID:147193
 
I have the following codein my game, but it dosent seem to work at all. When the mob logs in, the healthbar isnt there. can someone please tell me whats wrong with this and how to fix it?
mob/var/HealthOverlay

mob/proc/Bars()
usr.overlays -= usr.HealthOverlay
var/obj/HealthBar/O = new/obj/HealthBar
var/Length = 33
var/Percent = round((usr.health/usr.mhealth) * Length)
O.icon_state = "[(Percent>Length)?(Length-1):Percent]"
if(Percent==33)
O.icon_state = "33"
usr.HealthOverlay = O
usr.overlays += usr.HealthOverlay

obj/HealthBar
icon='meter.dmi'
icon_state="33"

Alittle forum searched revealed someone with the same problem here [link]

--Goz
In response to Goz
His problem dosent have really much to do with mine. Mine updates fine, but, the bar wont appear at all! Can someone just tell me how to fix the code?
Put a debug output in there that tells you what the icon state of the object is in that update function, then check to make sure you have the icon state in the icon file.
In response to Reinhartstar
Reinhartstar wrote:
His problem dosent have really much to do with mine. Mine updates fine, but, the bar wont appear at all! Can someone just tell me how to fix the code?

Your'e code is identical to his.

--Goz
No put usr in proc. Ungh.

Lummox JR
In response to Goz
I haven't read the post you linked to, but for the sake of argument two functions could use the exact same code yet have drastically different problems based on other parts of the program.
In response to Loduwijk
Loduwijk wrote:
I haven't read the post you linked to, but for the sake of argument two functions could use the exact same code yet have drastically different problems based on other parts of the program.

Yes but if you looked close enough it shows how to call the proc which is almost identical.

--Goz