Game Development Community

Ordering in SimSets

by Tim Saunders · in Torque Game Builder · 08/10/2006 (11:24 am) · 2 replies

Hello,

Is there a way to sort items in a simset once they have been put into it other than using the BringToFront or PushToBack commands?

Is there a way of swapping the position of two items? I have a Simset where the order is important throughout the set.

#1
08/10/2006 (4:31 pm)
As of version 1.1.1 (just released) there is a reorderChild function on SimSets... Here is an example of how you can use it.

Create the set and objects.
new SimSet(TestSet);
new ScriptObject(TestObject0);
new ScriptObject(TestObject1);
new ScriptObject(TestObject2);
new ScriptObject(TestObject3);

Now add them, with 3 being added before 2

TestSet.add(TestObject0);
TestSet.add(TestObject1);
TestSet.add(TestObject);
TestSet.add(TestObject3);
TestSet.add(TestObject2);

When I do listObjects I see

2786,"TestObject0": ScriptObject 
   2787,"TestObject1": ScriptObject 
   2789,"TestObject3": ScriptObject 
   2788,"TestObject2": ScriptObject

Now call this

TestSet.reorderChild(TestObject2, Testobject3);

and after another listObjects

2786,"TestObject0": ScriptObject 
   2787,"TestObject1": ScriptObject 
   2788,"TestObject2": ScriptObject 
   2789,"TestObject3": ScriptObject

It will place the first one passed before the second one passed.
#2
08/11/2006 (1:41 pm)
Great! Thanks very much for the prompt reply.

It's great to see TGB improving all the time, it has really come on leaps and bounds since I started using it. Keep up the good work.