Torque script multi-dim arrays
by Doug Pibal · in Technical Issues · 03/08/2006 (1:42 pm) · 2 replies
I'm new to torque script and trying to use arrays. (Ultimately I want to have a large 4-D array.)
When I do this in the console:
$c[2,5] = 10;
for ($a=0; $a<8; $a++)
{
for ($b=0; $b<8; $b++)
{
$c[a,b]= 77;
}
}
echo($c[2,5]);
The output is 10 instead of 77. What's going wrong with this simple example? Please help me understand how to use multi-dimensional arrays using torque script.
When I do this in the console:
$c[2,5] = 10;
for ($a=0; $a<8; $a++)
{
for ($b=0; $b<8; $b++)
{
$c[a,b]= 77;
}
}
echo($c[2,5]);
The output is 10 instead of 77. What's going wrong with this simple example? Please help me understand how to use multi-dimensional arrays using torque script.
About the author
#2
here is the code sample
$count=0;
for($a=0;$a<10;$a++)
{
for($b=0;$b<10;$b++)
{
for($c=0;$c<10;$c++)
{
$count++;
echo($carrier[$a,$b,$c]=getrandom(100));
}
}
}
echo("\n\ncount="@$count);
03/16/2006 (2:44 am)
If u r using any variable outside the function u have to use global variable. any variable used inside the function can be local variable .here is the code sample
$count=0;
for($a=0;$a<10;$a++)
{
for($b=0;$b<10;$b++)
{
for($c=0;$c<10;$c++)
{
$count++;
echo($carrier[$a,$b,$c]=getrandom(100));
}
}
}
echo("\n\ncount="@$count);
Torque 3D Owner Rubes