Game Development Community

Scripting Compund Variables

by Xavier "eXoDuS" Amado · in Torque Game Engine · 04/14/2002 (9:06 am) · 4 replies

I need to build a variable name dinamically like this:

I have a var %team which will contain the team name (for example red and blue)
And i want to access two different variables depending on the value of that.
These functions are:

MissionInfo.redObjectives
MissionInfo.blueObjectives

so i would need to build this variable name using the value of %team in the middle... but i cant seem to find a way to do it.. tried many things all give scripting errors :(

i tried for example: MissionInfo.[%team].Objectives... didnt work..
Anyone knows how to do this without having to use if statements?

#1
04/14/2002 (9:18 am)
If the variables already exist...

eval("MissionInfo."@ %team @"Objectives")

would return the value of the variable.
#2
04/14/2002 (10:05 am)
i tried this:

%teaminfo = eval("MissionInfo."@ $Team[%teamid].name @"Objectives");
echo (%teaminfo);

but it gave me a syntax error
#3
04/14/2002 (10:17 am)
Try this:

%teaminfo = "MissionInfo." @ $Team[%teamid].name @ "Objectives";
echo (%teaminfo);
#4
04/14/2002 (10:38 am)
got it!
solution:

eval("%teaminfo = MissionInfo."@ $Team[%teamid].name @ "Objectives;");
echo (%teaminfo);