ID:177872
 
I cant figure out how to get meters to work.
It's very simple

Check Meter Snippet made by my hero, Spuzzum.

I understand how meters works and I know the difference between meters and meters ( :-) ). But my prob is put meters on screen. I am making a game about MECHS and I want to put some meters on the screen ( I checked Hud Demo made by my other hero, Nadrew) but he used the meters on a Stat(), who check every time. I put the meters outside the Stat() and i made a lots of proc to check the new health, but don't works... If you can help me, i will be pleased...


Alvaro from Chile ( if you don't know where Chile is, search for it in SouthAmerica) :-)
In response to Hittokiri
Hittokiri wrote:
I understand how meters works and I know the difference between meters and meters ( :-) ). But my prob is put meters on screen. I am making a game about MECHS and I want to put some meters on the screen ( I checked Hud Demo made by my other hero, Nadrew) but he used the meters on a Stat(), who check every time. I put the meters outside the Stat() and i made a lots of proc to check the new health, but don't works... If you can help me, i will be pleased...

Can you show us the code you're using? Maybe we can figure out where the problem is.

Lummox JR
http://www.byond.com/hub/Sariat/BYONDcodeclient


HUD demo there. Has a health bar.
In response to Hittokiri
This is rather easy, try somthing like this.
obj/HPBar
icon = 'hpbar.dmi'
layer=1000000000
New(client/C)
screen_loc = "5,1"
icon_state = null
C.screen += src
Update(C)

proc/Update(client/C)
var/mob/M
for (M in world)
if (M.key == C.key)
src.icon_state = "[round(((M.Health / M.MaxHealth) * 100) / 3.33333333)]"
spawn (5) Update(C)


Make an icon, hpbar.dmi, Make 30 icon states. 0 being empty - 30 being full.

To make it display on the screen, in that code you see New(client/C) Inwhich is the client, screen_loc = "5,1" is where the object will be placed on the screen C.screen += src

Adds the object to the src's client.

But, to make it even appear in client, do this.
client
New()
new/obj/HPBar(src)
..()


Hope that helps you.

RaeKwon
In response to Sariat
I just wanted to ask you why the meter doesn't work for icon state 6 and 3? You may have corrected this problem but I was just wondering...

Punkrock546
In response to Punkrock546
Refer down to what i posted, it should fix all your Meter'ing needs!

RaeKwon
In response to RaeKwon
One question, why the "3.33333333" ?
In response to Sariat
well, Sariat, I understand the 3.33333 etc. if you put some numbers on the variables on the equation, you can figure that the result will be the name of the icon_state. So, because I am using 32 icons (not 30 like RaeKwon) I put 3.1, not 3.3...do u understand?

I can explain you in spanglish, if you want... :-))

See ya
In response to Hittokiri
oh, and thanks RaeKwon, the code works very well.

:-)