Game Development Community

Update Gui Text ?

by Jacob Wagner · in Torque Game Builder · 07/31/2005 (10:09 am) · 2 replies

Hi. All I need to do is update the text of a guiTextCtrl with script from within client.cs.

Here's the gui code I have:
new GuiControl(BaseControls) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 2";
   visible = "1";

new GuiTextCtrl(guiProspectGold) {
      profile = "GuiBaseTextProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "47 150";
      extent = "59 18";
      minExtent = "8 2";
      visible = "1";
      text = "Gold";
      maxLength = "255";
   };	
};

Here's what I've attempted to do in client.cs:

BaseControls.guiProspectGold.text = "Gold" SPC $player1.gold;
guiProspectGold.text = "Gold" SPC $player1.gold;

I even tried canvas.setContent
and canvas.pushDialog, but I either used them wrong, or they don't work for what I'm trying to do.

#1
07/31/2005 (11:06 am)
You want:
guiProspectGold.setText("Gold" SPC $player1.gold);

In the future, you can check the source code for useful console functions. What you would want to do is open up the related file (which in this case would be engine/gui/controls/guiTextCtrl.cc) and do a search for "consoleMethod." You would then find this:
ConsoleMethod( GuiTextCtrl, setText, void, 3, 3, "obj.setText( newText )" )
on line 23.

The source can be intimidating for non-programmers, but it is also really useful for things like this.
#2
07/31/2005 (5:08 pm)
Also if you have something you want to learn more about I find doing something like
guiProspectGold.dump();
Then going through each function play with it a few times. I have found some intresting things to do with that.