Page 1 of 1

Modify a singleton within a vector attribute ?

Posted: 23 Jun 2013 13:23
by amundsen
Hello,

I want to modify the "off" state color for some switches within 100-switches object.

If I use this code to change switch's #7 color:

Code: Select all

setattribute(Switches[7], 'colors',100);
it does not work even it the code is not colored in red by the editor.

This code change the color or all the switches, not just the color of a single one:

Code: Select all

setattribute(Switches, 'colors',100)[7];
I know I could store the colors in a big array and set all the switches in one operation but I'd prefer to avoid this way whenever possible because it might be repeated often and I think it's pretty unefficient to set all the switches's colors when you only want to change one.

Thank you in advance.

Re: Modify a singleton within a vector attribute ?

Posted: 23 Jun 2013 17:13
by Softcore
You only need to define the default color of all the switches (the whole array) when loading - with an on load script.

Having those defined (instead of letting it null when the template loads) your initial script will work - in other words, changing the properties of a switch[a] will work. I think it has something to do with the Lemur parser always thinking null equals 0 as a singleton and not as a vector. So when you haven't defined an array (vector), even if all its data is zero, it behaves as a singleton not as an array (vector).

Re: Modify a singleton within a vector attribute ?

Posted: 23 Jun 2013 19:59
by amundsen
Thanks Softcore !