below is my code. no errors in the debug window but it doesn't update when i run it. can any1 fix it or know what's wrong?
mob
Login()
..()
src.client.screen += new /obj/HUD/HPMeter
obj
var/num = 0
var/width
HUD
HPMeter
icon = 'hpglobe.dmi'
screen_loc = "1,1"
icon_state = "0"
layer = MOB_LAYER+10
width = 16
proc/Update()
if(num < 0)
num = 0
else if(num > width)
num = width
src.icon_state = "[round(src.num)]"
mob
proc
Update(mob/M as mob)
for(var/obj/HUD/HPMeter/HPM in M.client.screen)
HPM.num = (src.HP/src.MAXHP)*HPM.width
HPM.Update()
mob
Stat()
src.Update()</0>
ID:147866
![]() Oct 23 2003, 6:05 pm
|
|
Crispy wrote:
Why does /mob/proc/Update() have an argument? Try removing that argument, and using src instead of M throughout the proc. tried that. doesn't work. the hp meter still doesn't update. |
Are you sure that the obj's Update() proc is being called properly? Is the icon state non-existent?
To test those, put a line in /obj/proc/Update() to make sure it's actually being called. Something like this line would do: <code>world << "[type]/Update(): src.num is [src.num]"</code> Then we can see if it's actually getting that far, and try to fix it. |
Also, updating it on Stat() will make it laggier. I recommend simply calling it every time the HP changes. The easiest way of doing this is to have a special proc that's the only once that changes HP. If another proc needs to change HP, it calls that HP-changing proc. Then the HP-changing proc can call the mob's Update() proc.