help again :(

(gargola) #1

i lost some of my games cause my comp got screwed yesterday.anyway…i lost the health script and now i don’t remember how to “fix” the health problem.please take a look and see if you can help me: the cube represents the monsters that take away your health if you touch it.and the sphere represents the life.the problem is the same…when the health bar gets to the max(the limit) it keeps adding health points and the bar keeps growing.i tried the solutions you guys give me last time,but it doesn’t work anymore! :-? :frowning: please help me! :smiley:

ps: Saluk:i forgot to say thanx last time,sorry! :wink: :smiley:

(xintoc) #2

I didn’t know you needed script for health?

(gargola) #3

seems like you do need it! LOL anyway i advice that you get my game and take the health script from it…but wait till i fix the little problem. :wink: :smiley:

by the way,still need help! :smiley: :smiley:

(gargola) #4

going down and still no help…anybody? :frowning:

(saluk) #5

Ok, before you actually make the health bar bigger, you need to check and see if we’re at the max or not. So instead of:

blah blah blah
make health bigger
blah blah blah

you want:

if health < maxhealth:
    blah blah blah
    make health bigger
    blah blah blah

Get what I mean? I didn’t have much time, so I couldn’t actually look at your code, sorry. But you can probably figure it out.

(Pooba) #6

You can use an expression controller (unless this is a python script) and type in the health property and then a < than sign and then whatever the max health is.


(gargola) #7

yes it’s a python script :(.saluk…i’m afraid i’ll need more help than “code blah!” LOL :wink: something has changed in this code since you guys helped me and i don’t know why it doesn’t work now.i have tried anything to fix it myself,but i can’t make it work.please help!!! LOL :wink: :smiley:

(SeaCigar) #8

:-? … :slight_smile: well, gimme a little bit to look around. all the posting I have been doing lately has been on my grandma’s business computer, as MY computer is currently in the shop, getting repairs (CD burner, scanner, and printer issues.). When I get it back, I think I have a link that will teach you how to build a health bar. it should only be a matter of a day or so, so be patient, m’kay? Don’t hold me to it; I may have lost it if they had to reinitialise the PC, and if thats the case, I’ll have to look it up on the net again.

(gargola) #9

ok. thanx seacigar! i appreciate it. :wink: :smiley:

(saluk) #10

Well gargola, I looked at your script and it looks a bit over complicated. Here’s what I suggest:

Give the health bar a size ipo - add a key for full size on frame 100, then go to frame 1 and scale it all the way down to add a key there. Then give it always->and->ipo and make the ipo PROPERTY mode. Give the health bar a prop, call it frame. Put frame in the ipo actuator’s textbox. Set the frame prop to 100 (So it will be full at start). When it gets the message that you were hurt, subtract an amount from the frame prop. When it gets the message that you got health, add something to the prop. Then make sure the prop doesn’t go above 100 or below 1.

In python, you could have health be:

if own.frame &gt; 1:
   own.frame -= 1

and health plus be:

if own.frame &lt; 100:
   own.frame += 1

(gargola) #11

hum! ok…i’m going right now to try it saluk.thanx! :smiley:

(gargola) #12

that’s exactly what i neede saluk! thanx a lot man! :smiley:

(SeaCigar) #13

:slight_smile: well, thats good. I’ll keep looking for that link anyway, and post it… somewhere; everyone could use new tutorials, and a health bar tutorial is valuable, so yeah. good to know you got your problem solved.

(gargola) #14

Thanx Seacigar! :wink: :smiley: