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!