ID:176261
 
The energy bar in command and conquor, i want it so on one side it has the availabe energy and the other right next to it shows how much your using...and if you go over the max energy the energy used turns red...Or could somebody tell me a good tutorial where i can learn how to like make a bar HUD thing like the one im trying to make..THanks!

-Crio
Look up WizDragon's Hub Demo.
In response to Unknown Person
That would be HUD demo.
In response to Jotdaniel
when i try to make a second string of text it doesnt show...The words show but it doesnt show the numbers for MHP
/***********************************\
HUD Meters Demo, by WizDragon

This is to give you an idea of how to
put numbers and meters on a HUD. All
these icons may be used, and the code
(that's why it's a demo, heh). If you
find any bugs, please email them to
me at k.gibson@rcn.com. Thanks!
\***********************************/


world
maxx = 25 //define the size of the map
maxy = 25

mob
icon = 'Icons.dmi'
icon_state = "player"
Login()
new /obj/black(client) //create the hud objs so they are added to the screen
new /obj/HP(client)
new /obj/MHP(client)
var/num_position = 1
while(num_position <= 4) //quickly create 4 HUD numbers, each with positions of 1-4
new /obj/number(client,num_position)
num_position += 1
MHPRefresh()
HPRefresh()
..()
proc/HPRefresh() //this will refresh the HP numbers
var/text_HP = num2text(HP) //create a text string from your HP
if(lentext(text_HP) == 1)text_HP = " [text_HP]" //the text string MUST have a length of at least 4 to work correctly
if(lentext(text_HP) == 2)text_HP = " [text_HP]"
if(lentext(text_HP) == 3)text_HP = " [text_HP]"
for(var/obj/number/N in client.screen) //check for numbers in the screen
var/new_icon_state = copytext(text_HP,N.position,N.position+1)
if(N.icon_state != new_icon_state) //don't set the icon_state if unnecessary
N.icon_state = new_icon_state //set the icon state

proc/MHPRefresh() //this will refresh the HP numbers
var/text_MHP = num2text(MHP) //create a text string from your HP
if(lentext(text_MHP) == 1)text_MHP = " [text_MHP]" //the text string MUST have a length of at least 4 to work correctly
if(lentext(text_MHP) == 2)text_MHP = " [text_MHP]"
if(lentext(text_MHP) == 3)text_MHP = " [text_MHP]"
for(var/obj/numbers/N in client.screen) //check for numbers in the screen
var/new_icon_state = copytext(text_MHP,N.position,N.position+1)
if(N.icon_state != new_icon_state) //don't set the icon_state if unnecessary
N.icon_state = new_icon_state //set the icon stat
var
HP = 50
MHP = 50
verb
say(msg as text)
world << "[src]: [msg]"
changeHP(nm as num) //use this verb to test it out
HP += nm
if(HP > MHP)HP = MHP
if(HP < 0)HP = 0
HPRefresh() //refresh the HUD HP numbers

area
icon = 'Icons.dmi'
icon_state = "grass"

obj
New(client/C) //define the New proc for objs
C.screen += src //add the object to your screen
..() //perform default New stuff
black
layer = MOB_LAYER+1 //set the layer so that it appears over things
icon = 'Icons.dmi'
icon_state = "grey"
screen_loc = "1,1 to 11,1" //when this is added to your screen,
//it will appear from the first loc to the second loc
MHP
layer = MOB_LAYER+2
icon = 'Icons.dmi'
icon_state = "MHP"
screen_loc = "2,1:9"
HP
layer = MOB_LAYER+2
icon = 'Icons.dmi'
icon_state = "HP"
screen_loc = "5,1:16"

number
layer = MOB_LAYER+2
icon = 'Numbers.dmi'
screen_loc = "5,1" //the colon specifies pixel offsets
pixel_y = 16 //put this at the top of the HUD display
var/position = 0 //this will be used in refreshing the numbers
New(client/C,num_position)
..()
position = num_position
screen_loc = "5:[(position-1)*8],1" //set X pixel offsets so the numbers don't appear ontop of each other

numbers
layer = MOB_LAYER+2
icon = 'Numbers.dmi'
screen_loc = "4,1" //the colon specifies pixel offsets
pixel_y = 16 //put this at the top of the HUD display
var/position = 0 //this will be used in refreshing the numbers
New(client/C,num_position)
..()
position = num_position
screen_loc = "4:[(position-1)*8],1" //set X pixel offsets so the numbers don't appear ontop of each other

Please help me!
-Crio
In response to Koolguy900095
I wonder why WizDragon used the deprecated lentext() proc instead of length(). That was obsolete before HUDs were even possible.

Lummox JR
In response to Lummox JR
so i change that to what u just said? would that make it work? Edit:I just changed it and still the same prob
In response to Koolguy900095
Koolguy900095 wrote:
so i change that to what u just said? would that make it work? Edit:I just changed it and still the same prob

It wouldn't make it work any better, but it is a better proc to use. I was just voicing curiosity as to why WizDragon made such a weird choice to begin with.

Lummox JR
In response to Lummox JR
oh, ok...any tips why it dont work?...