Modify a singleton within a vector attribute ?

Discuss Lemur and share techniques.
Post Reply
amundsen
Regular
Posts: 62
Joined: 04 May 2013 19:11

Modify a singleton within a vector attribute ?

Post 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.
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Modify a singleton within a vector attribute ?

Post 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).
amundsen
Regular
Posts: 62
Joined: 04 May 2013 19:11

Re: Modify a singleton within a vector attribute ?

Post by amundsen »

Thanks Softcore !
Post Reply