HeroEngine Forums

HeroEngine Support => GUI Creation => Topic started by: Jrome90 on Aug 21, 11, 03:25:03 AM

Title: [Resolved] Problem with GUI labels
Post by: Jrome90 on Aug 21, 11, 03:25:03 AM
Using
Code: [Select]
healthP as NodeRef of Class GUIControl = FindGUIControlByName(me,"HP")
  healthP.defaultStatePresentation.color.r = 1
  healthP.defaultStatePresentation.color.g = 1
  healthP.defaultStatePresentation.color.b = 1
 
  healthP.text = hp + "/100"

If hp=100, I would expect the label to be:

"100/100" or "100 /100". But it is just "100".

Am I missing something?
Or does it just not work like that?

Thanks
Title: Re: Problem with GUI labels
Post by: FI-ScottZ on Aug 21, 11, 03:11:01 PM
There's a few possibilities.

Were there any error messages in the Chat, Console or Script Error panels?

I am assuming that hp is a number, probably Integer right?  I am not sure if this is what's going on, but perhaps with the number being first in the sum, the whole thing is converted to a number.  You could try putting an empty string first, like:

Code: [Select]
healthP.text = "" + hp + "/100"
Title: Re: Problem with GUI labels
Post by: Jrome90 on Aug 21, 11, 04:21:05 PM
You are right, It is an integer.

I apologize for not stating that I think it is adding them together. I notice that if you do: hp + "100" the outcome is "200".

Why didnt I think of adding "" at the beginning.
I will try that thanks.

Edit: adding "" first, works.
Thanks