Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Request for llColorName2Vector

Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
03-06-2007 13:29
I seem to have a bunch of different objects that contain scripts which translate color text strings ("red", etc) into vectors. I suspect that there are a fair number of other objects in-world that also contain these types of scripts.

It might be nice to be able to lose all this processing and static lists from resident scripts and have a simple lookup table on the sim side.

Maybe something like...
CODE
vector color = <1.0, 1.0, 1.0>; //default
if (llValidColorName (textString))
color = llColorName2Vector (textString);

...or maybe have it take a 'default color' argument and just do one call...
CODE
vector color = llColorName2Vector (textString, MY_DEFAULT_COLOR);


The W3C defines a list of 16 standard color names. It would be nice to have more but those could be used as a start..
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
03-06-2007 14:26
CODE
list color_map = [
"red",<1,0,0>,"maroon",<.5,0,0>,
"yellow",<1,1,0>,"olive",<.5,.5,0>,
"lime",<0,1,0>,"green",<0,.5,0>,
"aqua",<0,1,1>,"teal",<0,.5,.5>,
"blue",<0,0,1>,"navy",<0,0,.5>,
"fuschia",<1,0,1>,"purple",<.5,0,.5>,
"white",<1,1,1>,"silver",<.75,.75,.75>,"gray",<.5,.5,.5>,"black",<0,0,0>,
];

vector colorName2Vector(string name, vector none)
{
integer i = llList2List(color_map,[name]);
if(i==-1) return none;
return llList2Vector(color_map,i+1);
}