How can we return an Array?
by Tejaswin · in Torque Game Builder · 08/10/2010 (10:14 am) · 8 replies
Hi,
Can someone please tell me how to we return an Array from one function and get the array in other function and use the values?
Thanks in advance,
Tejaswin.
Can someone please tell me how to we return an Array from one function and get the array in other function and use the values?
Thanks in advance,
Tejaswin.
#2
08/10/2010 (12:11 pm)
Any time I need an array in script, I use a simset.
#3
08/10/2010 (12:54 pm)
Personally I try to do all my array processing in C++. :-)
#4
08/10/2010 (1:08 pm)
How much of a hassle is it for you when a new version of Torque comes out (assuming you upgrade)?
#5
Depending on what you need, a SimSet could work. Objects that belong to a SimSet can belong to other SimSets as well. See if this is desirable.
Objects within a SimGroup however can only belong to that one group at a time.
08/10/2010 (1:11 pm)
There's also an ArrayObject that you might want to try.Depending on what you need, a SimSet could work. Objects that belong to a SimSet can belong to other SimSets as well. See if this is desirable.
Objects within a SimGroup however can only belong to that one group at a time.
#6
08/10/2010 (1:27 pm)
I don't think the ArrayObject has made it into the stock TGB codebase yet. There is a resource out there, which the one that is in T3D is based on though.
#7
Ya it's a bit of a pain, but if you do any iPhone development you will quickly learn why heavy processing in script is not a good idea. :-)
08/10/2010 (2:45 pm)
Kevin:Ya it's a bit of a pain, but if you do any iPhone development you will quickly learn why heavy processing in script is not a good idea. :-)
#8
08/11/2010 (4:00 am)
Thank you guys for the replies, I will try to use Simset.
Torque Owner Alain Labrie
Ware-Wolf Games
In C++,
first declare a function like so:
Then you pass the array as a parameter of the fuction
In torquescript,
all variables are actually strings, that means there are no real arrays.
So to return a collection of variables:
function foobar(%this) { %val1 = 1; %val1 = 2; %val1 = 3; return %val1 SPC %val2 SPC %val3; }To use the "array"Hope this helps :-)