Help with HUD

Topics regarding Scripting with Reality Factory
Post Reply
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Help with HUD

Post by Masta_J »

Hi guys, trying to get a a working health bar for my player pawn. Sorry for the repost, but doesn't like anyone's reading or responding to my older thread anymore. I took Juutis's advice and used the built in players health bar. I sinchronised the player pawn and built in players health with the following bit of code, and set the health attribute to the same as my pawns in player.ini. However, if my player pawn gets hit once, he is still alive, but the health bar is reduced to 0. Any ideas on how to correct this?

HEALTHATTRIB [healthgood]
PAWNHEALTH [self.health]

if(self.in_pain)
{
self.think="Pain";
}
}]

Pain[()
{
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
self.think="Fight";
}
}]

Here's a copy of the health attribute code in the player.ini

[healthgood]
type = horizontal
frame = hud\hud_health_oxygen.bmp
framealpha = hud\a_hud_health.bmp
indicator = hud\hud_health_oxygeni.bmp
indicatoralpha = hud\a_hud_healthi.bmp
framex = 10
framey = 10
indicatoroffsetx = 75
indicatoroffsety = 0
indicatorwidth = 160
active = true
A good warrior knows his limits, but a great warrior finds his way around them.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

Patience, my friend. You would've gotten an answer to the other thread too. It just may take some days. :)
PAWNHEALTH [self.health]
I don't get this. Is this supposed to define the amount of the health attribute? If so, you should try using 'PAWNHEALTH [100]' or something like that.

Also you don't need a seperate pain order when in low level (unless you really want it). You can write:

Code: Select all

if(self.in_pain)
{
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
}
}]
Pain is only psychological.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

You are trying to set an attribute to a string. Let me explain:

SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");

PAWNHEALTH is a string, namely "self.health".
Because of this, you are doing this:
SetAttribute(HEALTHATTRIB,"self.health","Player");
This cannot work, because rf thinks you want to set the player's health attribute to "self.health". Attributes can only be numbers, no strings, and so rf just sets the attribute to 0.

If you want it to work, just type:
SetAttribute(HEALTHATTRIB,self.health,"Player");

This is different, because now rf sees that self.health is a value and no string.

hope this helps :)
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

Ah yes, I was being my dumb self again. Ignore my post and listen to Jay. :)
Pain is only psychological.
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Post by Masta_J »

Oh, Ok... Didn't realise that would make a differences. Tried it, and it works fine. Sorry for lack of patience, don't get much time to work on my game. All my time gets taken up by my pregnant wife and work. Thanks alot for da help guys. By the way, do you guys have any idea why I keep getting an error message saying, "Invalid session. Please resubmit the form," when trying to reply on the form?
A good warrior knows his limits, but a great warrior finds his way around them.
User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

Post by fps »

i have never gotten an error message like that.
it might be your computer.
1 wrote:
for the internet is a cruel and dark place at times, and there's sex and blood everywhere.

2 wrote:
You say that like it's a bad thing.

1 wrote:
You are a bad thing.
Post Reply