Arrays
by Daniel Buckmaster · in Torque Game Engine · 03/21/2007 (5:31 am) · 4 replies
How do I create arrays of a certain size? TDN and the documentation pages tell me how flexible Torque is with arrays, but they never told me how to create one!
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
03/22/2007 (8:17 am)
So basically a SimSet with index values. Well, thanks for the help.
#4
They are done like so:
$myArray[0]=%anyVal;
or
$myArray0=%anyVal; //both are the same!
Set up to fill some arrays?
for(%x=0; %x<5; %x++)
{
$myArray[%x]=%x;
}
Multi-dimensional:
$myArray[0_0]=%anyVal;
or
$myArray[0,0]=%anyVal;
or
$myArray0_0=%anyVal; //all 3 are the same!
03/24/2007 (2:12 am)
Arrays in script are easy and don't require the size, etc.They are done like so:
$myArray[0]=%anyVal;
or
$myArray0=%anyVal; //both are the same!
Set up to fill some arrays?
for(%x=0; %x<5; %x++)
{
$myArray[%x]=%x;
}
Multi-dimensional:
$myArray[0_0]=%anyVal;
or
$myArray[0,0]=%anyVal;
or
$myArray0_0=%anyVal; //all 3 are the same!
Employee Michael Perry
ZombieShortbus
function fillArray() { for(%i = 0; %i < 5; i++) %myArray[%i] = %i; echo(%myArray); } $pObject1 = new StaticShape(){...} $pObject2 = new StaticShape(){...} $pObject3 = new StaticShape(){...} $pArray[0] = $pObject1; $pArray[1] = $pObject2; $pArray[2] = $pObject3;There is, however, a resource that implements an even more powerful array system that acts more like a LinkedList but can still be accessed via an index.