Game Development Community

Changing the text value of GuiTextCtrl

by Dan Dias · in Torque Game Builder · 10/13/2005 (3:15 pm) · 3 replies

I'm not sure if this is the correct place for this, but it's the best I can think of at the moment.
I'm having an issue with changing the value of the GuiTextCtrl I've made.
new GuiTextCtrl(unitHP) {
         profile = "GuiTextProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "88 5";
         extent = "60 18";
         minExtent = "60 18";
         visible = "1";
         text = "HP: ";
         maxLength = "255";
      };
There it is. Now when I try to update that I do this...
function infoDialogUpdate(%obj)
{
  unitInfo.visible = "1";
  unitHP.text = "HP: "@%obj.health;
  unitMP.text = "MP: "@%obj.mana;
  Canvas.setContent(mainScreenGui);
}
Don't mind the unitInfo.visible... that's the parent dialog. I put the Canvas.setContent in there to try to see if that was the issue; I'm definitely not tied to that. I know there's something simple I'm missing...
Thanks in advance for any and all help!

#1
10/13/2005 (3:22 pm)
Use:

unitHP.setText("HP: "@%obj.health);
#2
10/13/2005 (3:24 pm)
Well, you might want to actually say what your issue is, it's not that clear. However, you set the text on a GuiTextCtrl with setText(), like so:

function infoDialogUpdate(%obj)
{
  unitInfo.visible = "1";
  unitHP.setText("HP: "@%obj.health);
  unitMP.setText("MP: "@%obj.mana);
  Canvas.setContent(mainScreenGui);
}

--
Hans
#3
10/13/2005 (4:40 pm)
Bah, sorry, under mental fatigue... you guessed my problem correctly. I can't believe I didn't see that function in the dump()! *sigh* Thanks guys works like a charm now!