ID:261626
 
Okay im working on a game just for fun for me and a few of my friends and ive ran into a slight problem with HUDs I havent used it before this. My problem is that when the useres health reaches the point to where a icon state is suposed to change nothing happens....heres the code i hope someone can help me

Proc:
obj/hud/life2/proc/Update(mob/C)
if(C.Health <= 50)
src.icon_state = "4"
sleep(10)
src.Update()

Ive tried (client/C) and C.mob.Health instead of what you see above and nothing changes
HUD:
obj/hud
life1
layer = MOB_LAYER + 1
icon = 'lifebar.dmi'
icon_state = "1"
New(client/C)
screen_loc = "14,1"
C.screen += src
life2
layer = MOB_LAYER + 1
icon = 'lifebar.dmi'
icon_state = "2"
New(client/C)
screen_loc = "15,1"
C.screen += src

Any help is apreciated..Thanks.

~Kros
How are you calling the proc, how did you define the player's mob. Is it simply /mob or mob/player or....?

~X
In response to Xooxer
Oh sorry should have explained that...The mob is just a mob hence the reason why I tried it with client first...the proc should be automaticly called considering its under obj/hud/life1/proc/ which would be the same as doing this

obj/thing
proc
ThingProc()
//etc.
take a look at wizdragon's HUDMeter demo
In response to K'ros Trikare
Um, I'm pretty sure you have to kick the loop off somewhere. The fact that you have a proc does not mean the proc is going to execute. Do you have something like this in the objects New() proc? Or are you calling the proc from some other location in your code?

obj/thing
New()
..()
spwan(1)
Thingproc()

proc/Thingproc()
// etc...
In response to Soori-99
I played around with the codeing after i checked out wizDragons demo and now theres no errors yet the icon state dosnt change ><!

obj/hud
New(client/C)
C.screen += src
..()
life1
layer = MOB_LAYER + 1
icon = 'lifebar.dmi'
icon_state = "1"
screen_loc = "14,1"
life2
layer = MOB_LAYER + 1
icon = 'lifebar.dmi'
icon_state = "2"
screen_loc = " 15,1"
New(client/C)
..()
spawn()Update(C.mob)
proc/Update(mob/M)
if(M.Health <= 50)
icon_state = "4"
spawn(2)Update(M)


Why must huds anoy me so much >< ><...Thanks for the help
In response to K'ros Trikare
After looking at my own hud objects, which I know work, the only diffrences I can see is that I did this:

obj/hud
New(client/C)
..()
C.screen += src

instead of:


obj/hud
New(client/C)
C.screen += src
..()

Also, my proc was a mob proc, not a proc of that object, though I'm sure you can make it an obj proc as well.
In response to Xooxer
Strange cause its not the problem of the object showing up on the users screen very strange problem to me...thanks for your help though.