ID:261503
 
client/New()
..()
new/obj/meter/health_meter(src)
mob
var
obj/meter/health_meter
obj/meter/magic_meter
max_health=100
HP=30
HPM=30
MP=30
MPM=30

New()
..()
src.health_meter=new
src.magic_meter=new
mob/Login()
TEST(src)
usr.loc=locate(1,1,1)
mob/proc/TEST()
src.health_meter.num=(src.HP/src.HPM)*src.health_meter.width
src.magic_meter.num=(src.MP/src.MPM)*src.magic_meter.width
src.health_meter.Update()
src.magic_meter.Update()
src.health_meter.name="[src.HP]/[src.HPM]"
src.magic_meter.name="[src.MP]/[src.MPM]"
spawn(1/90) TEST()
obj/meter/health_meter
New(client/C)
screen_loc = "1,10"
C.screen+=src
turf/Grass2
icon='grass.dmi'
obj/meter
icon='meter1.dmi'
icon_state="0"
var/num=0
var/width=30
proc/Update()
if(num<0)
num=0
else if(num>width)
num=width
src.icon_state="[round(src.num)]"

This code dosn't work...Duh but the problem is that the Meter dosn't start at 30 so could someone please help me.</0>
Strange Kidd wrote:
client/New()
..()
new/obj/meter/health_meter(src)
mob
var
obj/meter/health_meter
obj/meter/magic_meter
max_health=100
HP=30
HPM=30
MP=30
MPM=30

New()
..()
src.health_meter=new
src.magic_meter=new
mob/Login()
TEST(src)
usr.loc=locate(1,1,1)
mob/proc/TEST()
src.health_meter.num=(src.HP/src.HPM)*src.health_meter.width
src.magic_meter.num=(src.MP/src.MPM)*src.magic_meter.width
src.health_meter.Update()
src.magic_meter.Update()
src.health_meter.name="[src.HP]/[src.HPM]"
src.magic_meter.name="[src.MP]/[src.MPM]"
spawn(1/90) TEST()
obj/meter/health_meter
New(client/C)
screen_loc = "1,10"
C.screen+=src
turf/Grass2
icon='grass.dmi'
obj/meter
icon='meter1.dmi'
icon_state="0"
var/num=0
var/width=30
proc/Update()
if(num<0)
num=0
else if(num>width)
num=width
src.icon_state="[round(src.num)]"

This code dosn't work...Duh but the problem is that the Meter dosn't start at 30 so could someone please help me.


Whipe all that out, Simply do this for a meter.

obj/HPBar
icon = 'hpbar.dmi'
layer=1000000000
New(client/C)
screen_loc = "14,14"
icon_state = null
C.screen += src
Update(C)
proc/Update(client/C)
var/mob/player/M
for (M in world)
if (M.key == C.key)
src.icon_state = "[round(((M.HP / M.maxHP) * 100) / 3.33333333)]"
spawn (5) Update(C)

make a .dmi called hpbar make 30 icon states, 30 being full down to 1 being empty.

call it in client/New
client
New()
new/obj/HPBar(src)
..()

Done! that simple
- TheWizard
In response to RaeKwon
make a .dmi called hpbar make 30 icon states, 30 being full down to 1 being empty.

What about 0? There are 31 numbers between 0 and 30, and all are necessary if you're doing something like round((num / maxnum)*30, 1).
In response to Spuzzum
Spuzzum wrote:
make a .dmi called hpbar make 30 icon states, 30 being full down to 1 being empty.

What about 0? There are 31 numbers between 0 and 30, and all are necessary if you're doing something like round((num / maxnum)*30, 1).

My mistake.
- TheWizard