Passing Variables to a GUI
by Krister Collin · in Torque Game Engine · 05/03/2007 (1:17 am) · 3 replies
I am new to Torque, but loving it.
My problem is that I have created a menu that appears once the user presses a key, however, I do not know any way (or if there even is such a way) to pass variables to the GuiChunkedBitmap so that I can have something that looks like:
Strength:
Intelligence:
etc...
Many thanks in advance
My problem is that I have created a menu that appears once the user presses a key, however, I do not know any way (or if there even is such a way) to pass variables to the GuiChunkedBitmap so that I can have something that looks like:
Strength:
Intelligence:
etc...
Many thanks in advance
About the author
#2
Just give your GuiChunkedBitmap a name like this:
Now you could later in code set or retrieve variables simply by accessing them via the name, like:
Setting new variable:
KristerCollin.aNewVariable = "bla";
KristerCollin.aSecondNewVariable = 123;
KristerCollin.strength = 5000;
KristerCollin.hasVisitedLondon = false;
Retrieve the variables:
echo("KristerCollin.hasVisitedLondon: " @ KristerCollin.hasVisitedLondon);
echo("KristerCollin.aNewVariable: " @ KristerCollin.aNewVariable);
Does that help?
Martin
05/04/2007 (7:11 am)
To extend Caleb's answer:Just give your GuiChunkedBitmap a name like this:
new GuiChunkedBitmap([b]KristerCollin[/b]) {
...
...
...
};Now you could later in code set or retrieve variables simply by accessing them via the name, like:
Setting new variable:
KristerCollin.aNewVariable = "bla";
KristerCollin.aSecondNewVariable = 123;
KristerCollin.strength = 5000;
KristerCollin.hasVisitedLondon = false;
Retrieve the variables:
echo("KristerCollin.hasVisitedLondon: " @ KristerCollin.hasVisitedLondon);
echo("KristerCollin.aNewVariable: " @ KristerCollin.aNewVariable);
Does that help?
Martin
#3
05/06/2007 (12:14 am)
Also have a look at the GettingStarted.pdf. It shows you how to dynamically change GUI elements (a text value in this case) from scripts.
Torque Owner Caleb
Default Studio Name
Well all those are variables. So if you want to add some new ones, put this after "tile = "0";":
Of course, you would have to do this in your on file, this is just an example.