Game Development Community

Error setting a TextObject text. from script.

by Chris "Hyena" Vogel · in Torque Game Builder · 08/13/2009 (2:35 am) · 3 replies

function CSplash::onAdd(%this)		//CSplash is the class given to my T2DSceneObject in the Editor
									//VersionTextGui is the Name given to a T2DTextObject inside that SceneObject
{
	echo($Version);					 //This shows the Version Correctly
	VersionTextGui.text = $Version;	 //No Error here...
	echo(VersionTextGui.text);		 //This outputs a BUNCH of Gibberish into the console.
	
	//At this point if I bring the console up and type the echo command above, it shows "A", which is what it shows
	//on the screen. If I repeat the command to set the text to $Version, it then displays the version on the
	//screen. Why isn't this working from script? It works fine from the Console...
}

My questions are inside the code block. I don't know why it's doing this. I assume it has to do with the variable not existing when the script is run, but existing when the console commands are typed. I just don't know WHY it's not there when I try to initialize it from script. Any help?


#1
08/13/2009 (9:21 am)
Have you tried using .setText($Version) instead?
#2
08/13/2009 (12:19 pm)
It's a T2DTextObject, not a GUI Text field. I tried .setText and it tells me that function doesn't exist for this type of object.

Still haven't figured out why this isn't working.
#3
08/13/2009 (8:56 pm)
I think I know why this isn't working, I haven't got to test it yet.

I'm trying to set the value of an object inside a scene, on that scenes OnAdd() function. The scene's OnAdd() function is likely called before the object in question is actually added to the scene.

I definitely need to organize my code a bit and rethink a few things...