Can't change text onscreen
by Asura · in Torque Game Builder · 07/26/2011 (12:47 pm) · 4 replies
Hi all,
I'm having a bit of trouble with text objects.
I've created a text object with "healthGUI" in its name field, and wrote "health" in text. I want to display in-game a scalar value for how much health the player has remaining.
So in script, I've got the following:
%healthGUI.text = "blah";
(at the moment I'm just trying to get the text to change to ANYTHING)
But whilst I have echos in script to know that the program gets to this point, the text doesn't appear to change. My level is called "level1" under "Scene Graph Scripting", and I've got the above statement in a function called:
function level1::onLevelLoaded(%this)
So, can anyone tell me why the text does not change to "blah" when the program is ran?
I'm having a bit of trouble with text objects.
I've created a text object with "healthGUI" in its name field, and wrote "health" in text. I want to display in-game a scalar value for how much health the player has remaining.
So in script, I've got the following:
%healthGUI.text = "blah";
(at the moment I'm just trying to get the text to change to ANYTHING)
But whilst I have echos in script to know that the program gets to this point, the text doesn't appear to change. My level is called "level1" under "Scene Graph Scripting", and I've got the above statement in a function called:
function level1::onLevelLoaded(%this)
So, can anyone tell me why the text does not change to "blah" when the program is ran?
About the author
#2
This is almost certainly the part I'm missing. Can someone elaborate on this a touch?
07/28/2011 (12:03 am)
>> First of all u need to exec & push Gui in your script, This is almost certainly the part I'm missing. Can someone elaborate on this a touch?
#3
08/01/2011 (5:42 pm)
Well that depends on whether you're using a guiTextCtrl or a t2dtextObject. If you are using guiTextCtrl, god help you because I don't know how to use those. However, if you're using a t2dTextObject (which is the one you can place in the scene editor), then you would define it as new t2dTextObject(healthGUI){(stuff)}; as you've done and simply say "healthGUI.text = "blah";", without the % : )
#4
This.
08/02/2011 (8:26 am)
Quote: healthGUI.text = "blah"; //No need to put " % " sympol infront of this script
This.
Jebaraj Daniel
First of all u need to exec & push Gui in your script, After that you just use a GuiTextCtrl Name as a object
like
healthGUI.text = "blah"; //[No need to put " % " sympol infront of this script]
try like this