Help with object expression

I am trying to set a variable to an object’s variable in a while loop. What is the correct expression to use for say: Object0.VariableString(color) <— where “0” can be anything from 0 to 10.

I’ve tried the following with no success:

  1. “Object”+VariableString(Loop_Int).Variable(color)
  2. “Object”+VariableString(Loop_Int)+.Variable(color) <— yeah, don’t laugh, i am stupid lol.
  3. VariableString(“Object”+VariableString(Loop_Int)[ToString+(Variable(color))]

Anyone? Thanks in advance.

It is not possible this way.
If you want to set the color variable for each object to be the same, you can add all objects to an object group and then simply reference the group in the object name.

GroupName.VariableString(color) = “0;0;0”

If you would like to set different colors for different objects and you do prefer using a loop then what you could do is add the objects to an object group again, and then use an expression to get their name and store it in a variable and then compare it in a loop.

Condition:
At the beginning of the scene

Action:
DO = GroupName.ObjectName() to text of variable ‘name’ of object ‘GroupName’

And then you can use a loop.

Do = 0 to variable counter
Repeat 3 times:
Condition:
text of variable ‘name’ of object GroupName = “Object” + ToString(Variable(counter))

Action:
GroupName.VariableString(color) = “0;0;0”
Do + 1 to variable counter

So then you pick the instances of the first 3 object to change their color value but not the other 7 objects.

2 Likes

Ah ok! Thanks and much appreciated.