ID:166772
 
Well i was lookin to see if anyone would give me an example on how to make a hud health bar work that is more then 1 icon. I looked at Shadowdarke's hudmeter demo, It's not helpin me very much.
I suggest taking a more thorough look at the HUDmeter library, since its by far the easiest way to create HUD meters that I've encountered so far.
In response to Foomer
It is very good, except the fact I can't really find where and how to put it on something, Maybe an explanation on how to add it to the clients hud? Not just client.screen.
In response to Evidence
Its simple, look:

<code>HPmeter = new(src, "Health", "2,NORTH", "hp", "mhp", 'health.dmi')</code>

Just set the first arg to the mob or client you want it displayed for.
In response to Foomer
But i want to put it like at the bottom of the screen area, that's the part i don't get. Weres the loc?

In response to Evidence
Read the comments that come with the library:

<code>New(atom/M, Label, position, c_var, m_var, Icon, i_size, Dir, update) ARGS: M atom the meter is tracking. If M is a mob or client, the meter will automatically display to M. Label label for the meter position screen_loc for the meter c_var var name used for "current" value m_var var name used for "max" value Icon icon for this meter if Icon is a list, then this is a multi-tile meter: Icon[icon] = N where icon is the icon for each piece and N is the m_max for that piece. if N is null then use the default m_max. i_size number of icon states in Icon. Defaults to 30 Dir direction for multitile meter to expand Defaults to EAST update if set, the meter auto updates once when created.</code>
In response to Foomer
Thank you.
In response to Evidence
Ok, this is really frustrating me, if i change anything in New(), it is a bad argument error. I started to understand the Login() part a little for position'ing

mob
Login()
..()
Health = new(src, "Health", "2,SOUTH", \
"hp", "maxhp", list('HudH1.dmi' = 12, 'HudH2.dmi', \
'HudH2.dmi' = 12), 16)

The health bar is 3 icons long, it displays the first part full, second part at state 11(half full pretty much), and the third don't even display.

New() says it is suposed to auto Update, so i put in a damage health verb, Don't work. So what am i suposed to do, call a huge thing everytime i attack?

Join byond://68.40.133.210:1006 if anyone can help.
In response to Evidence
Evidence wrote:
The health bar is 3 icons long, it displays the first part full, second part at state 11(half full pretty much), and the third don't even display.

Are you sure the mob is at full health?


New() says it is suposed to auto Update, so i put in a damage health verb, Don't work. So what am i suposed to do, call a huge thing everytime i attack?

The update argument cause it to update once at the end of it's New() call. You still need to call the meter's Update() proc every time you make a change to the values involved, as described in the documentation and illustrated in the demo.


Join byond://68.40.133.210:1006 if anyone can help.

Connection failed. I guess you aren't hosting anymore.
In response to Shadowdarke
Offtopic:I've run into a few snags with Shadowdarke's myself, but they were all my errors anyway. His is a very easy and efficient library.

Ontopic: I've run into this problem before, and I'm trying to remember how to solve it.......Ok, is the full bar icon state the same for all 3? If yes, then all you need is = maxnum at the end of all three.

In response to Pyro_dragons
I model'd my health bar with the same length as the Knot one, and the same ammount of states.

Also, im hosting it right now if any of you see this.
byond://68.40.133.210:1006

Well, I'm not on my comp right now, but I will keep it up. I put in showcode demo, showcode something you think might fix the problem, and I will see it when I get back.
In response to Evidence
I figured out what the problem was.
list('HudH1.dmi' = 12, 'HudH2.dmi', 'HudH2.dmi' = 12)

returns a list with only two members.
'HudH1.dmi' with associated value 12, and 'HudH2.dmi' also with associated value 12. The second 'HudH2.dmi' is associated 12 with the 'HudH2.dmi' that already exists in the list.

You can have as many unassociated 'HudH2.dmi' as you like in the list, but once you add an associated value it's like the highlander. There can be only one.

You can get rid of the problem by using a separate icon for the end piece. Out of curiosity, if HudH2.dmi is 16 states, why did you use it again as the end peice with only 12 states?
In response to Shadowdarke
Holy crap dude, that was the problem. The most tiny thing, icon problem. I feel like such a lamer. Sorry for wasting all of your times, man. It was suposed to be HudH1, HudH2, and HudH3. :(

On a side note, how do i call Update(), i tried src.Update(), Update(), and src.Update(src).
In response to Evidence
Bump :) *Still wants to know how to call the Update()*
In response to Evidence
Evidence wrote:
Bump :) *Still wants to know how to call the Update()*

Anywhere in your code where you modify the mob's hp or maxhp, you simply add
Health.Update()
on the line after. For example:
mob/proc
ApplyDamage(amount)
hp = min(max(0,hp-amount),maxhp)
Health.Update()
if(!hp) Die()
LevelUp()
maxhp += rand(1,6)
Health.Update()