ID:163147
 
How do u code a health and chakra bar or what is the code for one??
How do you use the Search function? Do I just type in something like "health bars" and click Go, finding vast amounts of wonderfully informative demonstrations on whatever I need?

Answer: Yes.
In response to Kaiochao2536
eh that wasent helping him
In response to Lusifer
actually it is considering the Forum Search button can be your best friend. he can also search for demos since there are some that teach you how to code a health and chakra bar
In response to Monkeykid0049
i think he knows that but it would be nice to get help up front from some one who will reply
In response to Johan411
i kno about the iconinging stuff i wanna know how to code it in so it actualy make you lose health when u get hit
In response to Lusifer
Not really a health BAR but....

mob/Stat()
stat("Health",health)

Nice and simple :)
When you make the person hit the other just use:
usr.health-=x

Obviously x is the substitute for an unknown number(to me.)
Very simple.
In response to Dalkon_101
obj
hudMeters
health_01
icon='meter_01.dmi'
icon_state="0"
layer=99
New(client/c)
screen_loc="1,13"
c.screen+=src
health_02
icon='meter_02.dmi'
icon_state="0"
layer=99
New(client/c)
screen_loc="2,13"
c.screen+=src
mob
proc
updateHealth()
var/percent=round(src.health/src.maxhealth*100,10)
if(percent>100) percent=100
if(percent<0) percent=0
for(var/obj/hudMeters/o in src.client.screen)
o.icon_state=num2text(percent)
spawn(10)
src.updateHealth()

mob
proc/LoadBars()
new/obj/hudMeters/health_01(src.client)
new/obj/hudMeters/health_02(src.client)
src.updateHealth()

Then you'll want to put this after the login.

usr.LoadBars()

There you go just make the icons and change the names in code and you've got it :)


You can also do a Charka bar this way just trade out the health and maxhealth for chakra and max chakra or whatever variables are defined in your game.
In response to Bcale330
Please don't be a necroposter, this thread was 2 years old.

And do not show bad snippets if possible - this should be called when needed, not self-looping:
proc/TakeHp(...)
HP -= Amt
update_bar()