HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Problem with GUI labels  (Read 2300 times)

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
[Resolved] Problem with GUI labels
« 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
« Last Edit: Nov 01, 12, 08:44:53 AM by HE-Cooper »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Problem with GUI labels
« Reply #1 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"
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Problem with GUI labels
« Reply #2 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
« Last Edit: Aug 21, 11, 04:25:20 PM by Jrome90 »
Logged