ID:142933
 
Code:
world
view = "15x15"

turf/grass
icon = 'grass.dmi'

obj
var/num = 0 // This var is used later to help set the icon state
var/width = 100 // this is basically the number of icon states you have
var/rangemax // the range of the var that each tile of the meter will deal with
var/rangemin
HP
layer = MOB_LAYER+2 // Sets it at a layer above the background.
meter1
icon = 'meter.dmi'
icon_state = "0"
screen_loc = "16,2"
rangemax = 19
rangemin = 0
meter2
icon = 'meterm.dmi'
icon_state = "0"
screen_loc = "16,3"
rangemax = 39
rangemin = 20
meter3
icon = 'meterm.dmi'
icon_state = "0"
screen_loc = "16,4"
rangemax = 59
rangemin = 40
meter4
icon = 'meterm.dmi'
icon_state = "0"
screen_loc = "16,5"
rangemax = 79
rangemin = 60
meter5
icon = 'metert.dmi'
icon_state = "0"
screen_loc = "16,6"
rangemax = 99
rangemin = 80

obj/back
icon = 'white.dmi'
screen_loc = "16,1 to 17,15"
layer = MOB_LAYER+1


mob

var
HP = 20//health
MHP = 40//max health

Login() // Lets now add all the objects to the screen.
..()
src.client.screen += new/obj/HP/meter1
src.client.screen += new/obj/HP/meter2
src.client.screen += new/obj/HP/meter3
src.client.screen += new/obj/HP/meter4
src.client.screen += new/obj/HP/meter5
src.client.screen += new/obj/back



mob // Basic stat panel here, plus calling the Update() proc.
Stat()
statpanel("Character")
stat("Health","[src.HP]/[src.MHP]")
src.Update(src) // This calls the update proc to change icon states on the HUD meters





mob

proc/Update() // Compares the percentage of the
for(var/obj/HP/O in src.client.screen) // src's health with the range of
O.num = round((src.HP/src.MHP)*O.width)// each objects, then sets icon
if(O.num >= O.rangemax) // state accordingly
O.icon_state = "19"
if(O.num <= O.rangemin)
O.icon_state = "0"
if(O.num < O.rangemax && O.num > O.rangemin)
var/newnum = O.num - O.rangemin
O.icon_state = "[newnum]"

// Just some test verbs to see how well the meter works.
verb
addhp()
if(usr.HP < src.MHP)
usr.HP += 1
else
usr<<" Your already full on HP"
takehp()
if(usr.HP > 0)
usr.HP -=1
else
usr<<"Your already out of HP"


Problem description:

once I put this into my game and make the bars it compiles fine but once I run the bars do not appear I dont know what the problem is or where it would be. It works on the demo but not my game? thanks for any help!
-_- try Client/New() and the bars things that would work
In response to Pirata Inmortal
client/new()

Login() // Lets now add all the objects to the screen.
..()
src.client.screen += new/obj/hp/meter1
src.client.screen += new/obj/hp/meter2
src.client.screen += new/obj/hp/meter3
src.client.screen += new/obj/hp/meter4
src.client.screen += new/obj/hp/meter5
src.client.screen += new/obj/back
<dm/>

is this what you meen? because it dosn't work
In response to Nategrant
client/New()//capital on New() man

and delete the login() o.o lol but keep using mob/Login()
In response to Pirata Inmortal
like this?
client/New()
src.client.screen += new/obj/hp/meter1
src.client.screen += new/obj/hp/meter2
src.client.screen += new/obj/hp/meter3
src.client.screen += new/obj/hp/meter4
src.client.screen += new/obj/hp/meter5
src.client.screen += new/obj/back

i get these 6 errors..
hpbartester.dm:52:error:src.client.screen:undefined var
hpbartester.dm:53:error:src.client.screen:undefined var
hpbartester.dm:54:error:src.client.screen:undefined var
hpbartester.dm:55:error:src.client.screen:undefined var
hpbartester.dm:56:error:src.client.screen:undefined var
hpbartester.dm:57:error:src.client.screen:undefined var
im kinda noob so could u mabey post the code?
In response to Nategrant
hmmm its not the only problem (hp/maxhp)*O.blah blah how about if you put (src.hp/src.maxhp *100)

client
New()
if(src.key == "Guest")
del src
..()
src.screen += new/obj/howeveritscalled
src.screen += new/obj/howeveritscalled
src.screen += new/obj/howeveritscalled
src.screen += new/obj/howeveritscalled
src.screen += new/obj/howeveritscalled
src.screen += new/obj/howeveritscalled


NOTE:fix dm tags hehe btw rename all the howeveritscalled


...:::Pirata Inmorta:::...
In response to Pirata Inmortal
it works ok so far thanks for the help ill come back if i run into any other problems. Agian tysm!!! (you'll definatly be mentioned in credits)
In response to Nategrant
np im here for help not just for code my own things