Change Symbol
by Tyler Slabinski · in Torque Game Builder · 07/28/2009 (7:23 am) · 5 replies
function t2dScenegraph::onLevelLoaded(%this, %scenegraph)
{
%text = getRandomSymbol();
$symbol = new t2dTextObject() {
scenegraph = SceneWindow2D.getSceneGraph();
canSaveDynamicFields = "1";
position = "-20.000 17.500";
size = "20.000 25.000";
FlipX = "1";
Layer = "1";
BlendColor = "0 0 0 1";
text = %text;
font = "Arial";
wordWrap = "1";
hideOverflow = "1";
textAlign = "Center";
lineHeight = "25";
aspectRatio = "1.21809";
lineSpacing = "0";
characterSpacing = "0";
autoSize = "1";
fontSizes = "160";
textColor = "0 0 0 1";
mountID = "2";
};
}
function getRandomSymbol()
{
%symbolList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+~{[}]|;:<>?/";
return getSubStr($symbolList, getRandom(0,strlen(%symbolList)), 1);
}The above code is suppose to do this:
When the level loads up, get a random symbol from the list %symbolList and make the text object display that symbol.
Anyone know what's wrong with this? It doesn't seem to be doing anything. It doesn't show any error, and yes I have executed it.
About the author
Working on prototype.
#2
That saved me the trouble of having a couple dozen switch statements...
07/28/2009 (12:10 pm)
Tested it in the console, and it works like a charm!That saved me the trouble of having a couple dozen switch statements...
#3
07/28/2009 (12:34 pm)
Cool! you should church it up and use it like this though... :)function getRandomSymbol()
{
%symbolList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+~{[}]|;:<>?/";
return getSubStr($symbolList, getRandom(0,strlen(%symbolList)), 1);
}
#4
07/28/2009 (5:03 pm)
I changed the subject. Can anyone help with this?
#5
www.garagegames.com/community/forums/viewthread/64193
07/29/2009 (7:04 am)
Have you seen this thread?www.garagegames.com/community/forums/viewthread/64193
Torque Owner Patrick W
Dream. Build. Repeat.
$symbolList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+~{[}]|;:<>?/"; function getRandomSymbol() { %symbolIndex = getRandom(0,strlen($symbolList)); return getSubStr($symbolList, %symbolIndex, 1); }