ID:263190
 
Code:
    Health
layer=MOB_LAYER+56
icon='Hud.dmi'
icon_state="Health"
New(client/C) screen_loc = "4,1", C.screen+=src
Stamina
layer=MOB_LAYER+56
icon='Hud.dmi'
icon_state="Stamin"
New(client/C) screen_loc = "7,1", C.screen+=src
Stamina_
layer=MOB_LAYER+56
icon='Hud.dmi'
icon_state="A"
New(client/C) screen_loc = "8,1", C.screen+=src
Bpnumber
layer = MOB_LAYER + 56
icon = 'Numbers.dmi'
screen_loc = "2,1"
pixel_y = 16
var/position = 0
New(client/C,num_position)
position = num_position
screen_loc = "2:[(position-1)*8],1"
C.screen+=src
Hpnumber
layer = MOB_LAYER + 56
icon = 'Numbers.dmi'
screen_loc = "5,1"
pixel_y = 16
var/position = 0
New(client/C,num_position)
position = num_position
screen_loc = "5:[(position-1)*8],1"
C.screen+=src
Stamnumber
layer = MOB_LAYER + 56
icon = 'Numbers.dmi'
screen_loc = "8,1"
pixel_y = 16
var/position = 0
New(client/C,num_position)
position = num_position
screen_loc = "8:[(position-1)*8],1"
C.screen+=src

Percent
layer=MOB_LAYER+56
icon='Numbers.dmi'
icon_state="%"
New(client/C) screen_loc = "3,1", C.screen+=src
Percent2
layer=MOB_LAYER+56
icon='Numbers.dmi'
icon_state="%"
New(client/C) screen_loc = "6,1", C.screen+=src
Percent3
layer=MOB_LAYER+56
icon='Numbers.dmi'
icon_state="%"
New(client/C) screen_loc = "9,1", C.screen+=src
mob/proc
BPRefresh() // The hp proc. Call this whenever hp adds and or subtratcs
for(var/obj/Bpnumber/H in client.screen) // For var/hpnumber/N in client.screen
H.icon_state = "[copytext(num2text(round(battlepower/maxbp)*100),H.position,H.position+1)]"//Changes the icon state to what's needed

mob/proc
HPRefresh() // The hp proc. Call this whenever hp adds and or subtratcs
for(var/obj/Hpnumber/D in client.screen) // For var/hpnumber/N in client.screen
D.icon_state = "[copytext(num2text(round(Health/maxhp)*100),D.position,D.position+1)]"//Changes the icon state to what's needed

mob/proc
STAMRefresh() // The hp proc. Call this whenever hp adds and or subtratcs
for(var/obj/Stamnumber/A in client.screen) // For var/hpnumber/N in client.screen
A.icon_state = "[copytext(num2text(round(stam/stamax)*100),A.position,A.position+1)]"//Changes the icon state to what's needed




client
New()
new/obj/Bar_1(src)
new/obj/Bar_2(src)
new/obj/Bar_3(src)
new/obj/Bar_4(src)
new/obj/Bar_5(src)
new/obj/Bar_6(src)
new/obj/Bar_7(src)
new/obj/Bar_8(src)
new/obj/Bar_9(src)
new/obj/Bar_10(src)
new/obj/Bar_11(src)
new/obj/Bar_12(src)
new/obj/Battlepower(src)
new/obj/Power_Up(src)
new/obj/Power_Down(src)
new/obj/Health(src)
new/obj/Stamina(src)
new/obj/Stamina_(src)
new/obj/Percent(src)
new/obj/Percent2(src)
new/obj/Percent3(src)
..()


Problem description: Okay, thats the code for my hud. But when I want the numbers on it change with the procs HpRefresh ect. It doesn't work. The proc I put it down here. I put it in my training system and tryed it. It doesn't change to like 66% It just goes straight to 0% when it's really 90% This is what I put:
 
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()
//I only posted some of the coding. The rest is fine.
New(client/C) screen_loc = "9,1", C.screen+=src


Does that even compile? It's supposed to be
New(client/C) {screen_loc = "9,1";C.screen+=src}


And just what the poo are you trying to do with this? Sorry if this is correct, but I've never seen anything like it. o.o
screen_loc = "2:[(position-1)*8],1"



And we need to see how you call it, an example given by you provides us with very little information. There could be anything.
In response to Mysame
Hmmm... Well, lets say I have on the hud:

Stamina 100% I've put the proc in for refreshing stamina, but insted of going to 99% it goes too 0%.

Edit: The best example for something like this is Dragonball: Millenia.
In response to Team Echo
You said that, and we know what hud bars are (-_-), but we need to see how you call the refresh procs, and WHERE you call them. Could be very important.

That, and recheck your formulas. Just got up, but I don't see anything wrong.
In response to Mysame
mob
verb
Meditate()
set category="Train"
//if(usr.med == 1 && usr.maxki > 2)
//usr.verbs+= /obj/Power_Up/verb/Power_Up
//usr.verbs+= /obj/Power_Down/verb/Power_Down
if(usr.class == "Healer" && usr.race == "Namekian" && usr.med == 1 && usr.maxki >= 100)
usr.verbs+= /mob/Admin/verb/Unlock_Potential
if(usr.rest==0 && usr.train==0 && usr.swimming == 0)
if(usr.med==0)
usr << "<font color = red><font size=1>*You begin meditating.*"
usr.med=1
usr.move=0
usr.icon_state="meditate"
src.move=0
if(usr.med == 1 && usr.maxki >= 5)
usr.verbs+= /mob/Skill/verb/Ki_Blast
if(usr.med == 1 && usr.maxki >= 5)
usr.verbs+= /mob/Skill/verb/Sense
if(usr.class == "Healer" && usr.race == "Namekian" && usr.med == 1 && usr.maxki >= 100)
usr.verbs+= /mob/Admin/verb/Unlock_Potential
usr.meditate()
else
usr << "<font color = red><font size=1>*You stop meditating.*"
usr.med=0
src.move=1
usr.icon_state=""

proc
meditate()
medloop
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()
if(usr.med==1)
if(usr.resting==0 && usr.train==0 && usr.swimming == 0)
usr.maxbp+=((usr.powergain/2)*(1+(usr.grav/50)))
usr.battlepower+=((usr.powergain/2)*(1+(usr.grav/50)))

usr.maxhp+=((usr.powergain/2)*(1+(usr.grav/50)))
usr.Health+=((usr.powergain/2)*(1+(usr.grav/50)))

usr.strength+=((usr.powergain/2)*(1+(usr.grav/50)))
usr.ki+=((usr.powergain)*(1+(usr.grav/50)))
usr.maxki+=((usr.powergain)*(1+(usr.grav/50)))

usr.speed+=((usr.powergain/2)*(1+(usr.grav/50)))

usr.endurance+=((usr.powergain/2)*(1+(usr.grav/50)))

usr.defense+=((usr.powergain/2)*(1+(usr.grav/50)))

usr.offense+=((usr.powergain/2)*(1+(usr.grav/50)))

if(usr.battlepower < usr.maxbp)
usr.battlepower+=((usr.maxbp/120)*usr.healrate)

if(usr.Health < usr.maxhp)
usr.Health+=((usr.maxhp/120)*usr.healrate)

if(usr.stam < usr.stamax)
usr.stam+=((usr.stamax/120)*usr.healrate)

usr.stam+=(usr.stamgain/2)
usr.stamax+=(usr.stamgain/2)

usr.sp+=(usr.skillgain*2)
usr.sprec+=(usr.skillgain*2)

usr.focus()

usr.powergain+=usr.powergainget

usr.Gain_Progression()

if(usr.grav>1)
if(usr.grav/usr.gravmastery >1)
usr.Health-=(usr.maxhp/150)*((usr.grav/usr.gravmastery)*(usr.grav/usr.gravmastery))
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()
if(usr.Health <= 0)
if(usr.grav > (usr.gravmastery*2))
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()
usr.die()
else
usr.ko()
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()
if((usr.grav/usr.gravmastery) > 0.9)
usr.gravmastery+=(usr.grav/10000)
src.BPRefresh()
src.HPRefresh()
src.STAMRefresh()

sleep(10)

goto medloop

Okay, places in there. Same with train.
mob
Login()
var/bpspot = 1
while(bpspot<=15)
new/obj/Bpnumber(client,bpspot)
bpspot ++
var/hpspot = 1
while(hpspot<=15)
new/obj/Hpnumber(client,hpspot)
hpspot ++
var/stamspot = 1
while(stamspot<=15)
new/obj/Stamnumber(client,stamspot)
stamspot ++

Thats that starting login thing. Thats just to get it to work.
In response to Team Echo
1. No put usr in proc, ungh.
2. No put goto for loop, ungh.
3. No use boolean vars, ungh.

Bolean vars;
// When checking for TRUE/FALSE values.

if(var==1) // Wrong.
if(var) // Right!

if(var==0) // Wrong.
if(!var) // Right!
You're rounding bp/maxbp before multiplying by 100.
BP  =  90
Max = 100

90 / 100   = 0.9

round(0.9) =   0

0 * 100    =   0


And for Mysame, you can specify pixel offsets in screen_loc with the colon. =)
In response to YMIHere
ROFL, fixed it. The problame was
 "[copytext(num2text(round((battlepower/maxbp)*100)),H.position,H.position+1)]"
(battlepower/maxbp)*100)//thats what it use to be.