It is also non-destructive, in that it colours sides, but takes a note of what colour they were so you can reset them.
To use, simply create a script in the object you wish to colour, then copy/paste this into it and save. Once it has saved it will tell you it is ready at which point you may simply touch your object to colour the sides, then touch again to reset them to their previous colour.
This is best used when applied to an object with no textures, or transparency applied to it yet, though most objects will work fine.
CODE
list colours = [
"red", <1.0,0.0,0.0>,
"green", <0.0,1.0,0.0>,
"blue", <0.0,0.0,1.0>,
"yellow", <1.0,1.0,0.0>,
"cyan", <0.0,1.0,1.0>,
"magenta", <1.0,0.0,1.0>,
"orange", <1.0,0.5,0.0>,
"violet", <1.0,0.0,0.5>,
"white", <1.0,1.0,1.0>,
"black", ZERO_VECTOR,
"grey", <0.5,0.5,0.5>,
"pink", <1.0, 0.75,0.75>,
"brown", <0.529, 0.318, 0.118>,
"dark red", <0.33,0.0,0.0>,
"dark blue", <0.33,0.0,0.0>,
"dark green", <0.33,0.0,0.0>
];
integer colourListSize;
integer colourStride = 2;
list oldColours;
default {
state_entry() {
colourListSize = llGetListLength(colours) / colourStride;
state ready;
}
}
state ready {
state_entry() {llOwnerSay("Face colour is ready, touch object to colour code the sides"); }
touch_start(integer x) {
oldColours = [];
x = llGetNumberOfSides();
if (x > colourListSize)
llOwnerSay("This object has more faces than I have colours to assign! "+
"Please enter more to the list");
else {
integer i; integer l;
for (i = 0, l = 0; i < x; ++i, ++l) {
oldColours += [llGetColor(i)];
llOwnerSay("Side "+(string)i+" was coloured "+
(string)llList2String(colours, l++));
llSetColor(llList2Vector(colours, l), i);
}
llOwnerSay("Colouring complete, touch again to reset colours");
state done;
}
}
}
state done {
touch_start(integer x) {
integer i; x = llGetListLength(oldColours);
for (i = 0; i < x; ++i) llSetColor(llList2Vector(oldColours,i), i);
oldColours = [];
state ready;
}
}