ID:270180
 
how do i add a over head stat meter??
i have a stat meter but how do i get it as an overlay thx in advance


Zog
Over head I am guessing you mean over the player's icon. If you do mean that, you can use overlays, and update it everytime the meter changes.

If you mean HUD (Heads Up Display) Meter, you may want to look at Shadowdarke's HUDMeter. It is a great library, and amazinly easy to use.


-Doh
In response to XxDohxX
no not in the hud i mena overhead (over the mobs icon) as if it were clothes that is permentnt
In response to Zog 200
Well that was explained in my previous post.
In response to XxDohxX
yea but i want to know how to get it over head i got one in stat panel by
                stat("Health:",src.health_meter)

but how would i get it as a mob ovelay
src.overlays+=src.health_meter //??????????<-----does not work

but over head ??
In response to Zog 200
I think I am a tad confused. Do you mean an actual bar, that goes down when he is damaged and goes up when healed, or do you mean a number? You could probally search for both and find demos/libraries on them. Just take the time to search.

-Doh
In response to XxDohxX
the actual BAR over head yes and ihave benn looking 4 along time and alos the ones that could be it dont work >.> (cant download um or faild to unzip)
In response to Zog 200
az_TaskBar is a great demo/library. Check it out.


-Doh
In response to Zog 200
In response to Joseph Constantine
Constantine
i am sorry about my lack of discription in my request but all what u have said i know and have tried but with all my cretive effots have falied so iam asking u how do i get this pice of codeing as an overlay


this is exactl what iam woking with plz help
mob
var
obj/meter/health_meter
max_health = 10

obj/meter/magic_meter
magic = 100
max_magic = 100

//etc.

New()
..()
src.health_meter = new //initialises the meters
src.magic_meter = new

Stat()
//calculate each meters' number (as a percentage of the total icon_states)
src.health_meter.num = (src.health/src.max_health)*src.health_meter.width
src.magic_meter.num = (src.magic/src.max_magic)*src.magic_meter.width

//update the meters to take on the new changes
src.health_meter.Update()
src.magic_meter.Update()

//change the meters' names to reflect the current numbers
src.health_meter.name = "[src.health]/[src.max_health]"
src.magic_meter.name = "[src.magic]/[src.max_magic]"

//alternatively, change their names to nothing
//comment out the above name changes and uncomment the below ones to use this method
//src.health_meter.name = ""
//src.magic_meter.name = ""

mob
obj/meter
icon = 'meter.dmi'
icon_state = "0" //that's zero, not ( ) or O

var/num = 0 //the current unrounded icon_state number
var/width = 30
//If you have icon_states from "0" to "30" within your
// meter.dmi file (i.e. you have 31 icon_states in total),
// use this number as it is.

//Change it if you have any other number of states;
// if you have states from "0" to "5", this number would
// be 5 instead.

proc/Update()
if(num < 0) //if the meter is negative
num = 0 //set it to zero
else if(num > width) //if the meter is over 100%
num = width //set it to 100%
src.icon_state = "[round(src.num)]"



that i the exact codeing this works fine in the stat panel but how do i get this as an overlay



**sorry for the size of the codeing*
In response to Zog 200
In response to Joseph Constantine
can any one teach how to get this DARN thing over the top of the mob icon >.>
I explained to someone else a while ago on how to make a stat meter on a player: [link]

~~> Unknown Person
In response to Unknown Person
In response to Joseph Constantine
y is this so hard .....
mob
var
obj/healthbar
New()
..()
spawn()
var/obj/hpbar = new/obj
hpbar.icon = 'meter.dmi'
hpbar.icon_state = "30"
hpbar.pixel_y = 30
src.healthbar = hpbar
src.overlays += hpbar

proc/refresh_hud()
var/formula = "[round((maxhp/hp)*10,1)]"
if(healthbar)
if(src.icon_state != formula)
healthbar.icon_state = formula
else
src.statmeter_img = image('meter.dmi',src, formula)
world << src.healthbar

this is what i understand so far but that does not work

help ....
In response to Zog 200
mob
var
obj/meter/health_meter // variable for the stat panel health meter
New()
..()
src.health_meter = new // create a new health/mana_meter when a mob is created

mob/Stat()
stat("Name:",src.name)
stat("Class:",src.class)
stat("Level:",src.level)
stat("Health:",src.health_meter)
stat("Mana:",src.MP / src.MMP)
stat("Strength:",usr.Str)
stat("Defense:",usr.Def)
stat("Experience:","[usr.Exp]/[usr.Mexp]")
stat("Gold:",src.gold)
statpanel("Inventory")
stat(src.contents)
src.Update(src) // This calls the update proc to change icon states on the HUD meters
src.health_meter.num = (src.HP/src.MHP)*src.health_meter.width // this sets percentage, which you get your frame number from
src.health_meter.Update() // run the update proc on the stat panel meters to make them reflect your current health/mana src.mana_meter.Update()
src.health_meter.name = "[src.HP]/[src.MHP]" // this shows the max and current hp/mana after the stat panel meter
obj

var/num = 0 // current unrounded icon_state number
var/width // number of frames in your meter, if you have frames 0 = 30 then this is set to 30



//P.S. when you make your health bar bar change the width to how ever many icon states there are.
//If you want 1 of mine just IM me at Hoff0992 or leave another post.



meter // this is the stat panel health meter
icon = 'smallhglobe.dmi'
icon_state = "0"
name = ""
width = 11

meter1 // hud health meter, more frames, larger, and much better detail
icon = 'smallhbar.dmi'
screen_loc = "6,6"
icon_state = "0"
layer = MOB_LAYER+10
width = 20

proc/Update()// NOTE: this is the only part of the code made by Spuzzum, I would change it but I see no point in doing this.
// NOTE: it also has the original commenting from Spuzzum.
if(num < 0) //if the meter is negative
num = 0 //set it to zero
else if(num > width) //if the meter is over 100%
num = width //set it to 100%
src.icon_state = "[round(src.num)]" // this sets the icon state of the meter to its rounded off number

mob

proc/Update(mob/M as mob)
for(var/obj/meter1/N in M.client.screen)
N.num = (src.HP/src.MHP)*N.width
N.Update()
MP -= 1





This is a Demo i found on byond a while ago and edited it
myself. If you need any more help like if its not showing or anything just leave another message.
In response to Animekid09
now whan i complie and run in the text box this come up

Setting network delay to 0.
Zog 200 has logged in.
runtime error: Division by zero
proc name: Stat (/mob/Stat)
usr: Zog 200 (/mob/Character)
src: Zog 200 (/mob/Character)
call stack:
and the bar does not do down with the health
In response to Zog 200
http://h1.ripway.com/Hoff0992/icons.zip


Go there and download those stat bars and try to use them instead.