This function takes in a hex color code and concerts it into an RGB vector for LSL color. There is a basic check for if there's a # randomly in the string but no validation of the hexcode.
//Convertes a hexcode into vector
vector hex2Vec(string hex)
{
//remove poud sign from hexcode
if(llSubStringIndex(hex, "#") == 0)
{
hex = llDeleteSubString(hex, 0, 0);
}
//sainty check to make sure there's no pound sign
else if (llSubStringIndex(hex, "#") > 0)
{
llOwnerSay("Invalid hexcode: "+hex);
return ZERO_VECTOR;
}
float r = (float)("0x"+llGetSubString(hex, 0, 1))/255;
float g = (float)("0x"+llGetSubString(hex, 2, 3))/255;
float b = (float)("0x"+llGetSubString(hex, 4, 5))/255;
return <r,g,b>;
}