General
Modify a singleton within a vector attribute ?
Started by amundsen on .
Sign in or create an account to join the conversation.
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:
This code change the color or all the switches, not just the color of a single one:
Thank you in advance.
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:
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:
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.
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).
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).
Thanks Softcore !