Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Setting which colors will change in a script

Rocky Rutabaga
isn't wearing underwear™
Join date: 14 Apr 2006
Posts: 291
03-07-2007 05:58
I've got a couple of different freebie color change/generator scripts. However, they run through every color. How can I specify that only a certain set of selected colors will fire? Is there a color chart that lists all the "coordinates" or numbers for the colors so I know which ones are which?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-07-2007 06:31
From: Rocky Rutabaga
I've got a couple of different freebie color change/generator scripts. However, they run through every color. How can I specify that only a certain set of selected colors will fire? Is there a color chart that lists all the "coordinates" or numbers for the colors so I know which ones are which?


There are a couple of posts that do cover this. try this one
Rocky Rutabaga
isn't wearing underwear™
Join date: 14 Apr 2006
Posts: 291
03-07-2007 07:18
Cool. Thanks so much!
Rocky Rutabaga
isn't wearing underwear™
Join date: 14 Apr 2006
Posts: 291
Duh-ee-ah.
03-07-2007 13:28
So where does one put the RGB numbers in the script?

(Sorry, folks. I'm a good builder, I make kick-butt smart alecky T shirts, but I'm all thumbs when it comes to scripts. If you could make even me understand scripting, you would be a billionaire about now. Which reminds me, has anyone written a "Scripting for Dummies" yet?
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
03-07-2007 15:58
LSL treats colors as vectors to represent the three parts of R, G, and B.

Traditional RGB values go from 0 to 255 for each third. In LSL you have to convert to decimal form by dividing each part by 255. To convert from LSL back to RGB, just multiply each part by 255.

By doing that:

white (normally 255,255,255) becomes <1.0, 1.0, 1.0>
black (normally 0,0,0) becomes <0.0, 0.0, 0.0>
grey (normally 128,128,128) becomes <0.5, 0.5, 0.5>
red (normally 255,0,0) becomes <1.0, 0.0, 0.0>
green (normally 0,255,0) becomes <0.0, 1.0, 0.0>
blue (normally 0,0,255) becomes <0.0, 0.0, 1.0>

These conversions are what is being represented in the long list in the link given to you above.

Without looking at your particular script, I couldn't tell you more about what exact changes you are looking to make.
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
03-07-2007 16:42
Hiya, Rocky!
Try HERE for more info:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=color

This won't answer ALL your questions, but it shows color swatches and the vector that defines them. And there's a 'function' that will convert from traditional RGB values to the SL equivalent.

==== Edit:
/327/20/138429/1.html
is another huge list o' colors ;)
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
03-07-2007 17:29
this is a widget that i made back when .... its old its simple and it works

CODE

//<--- Osgelds Handy Dandy Color Converter --->//
default
{
changed(integer change)
{
if (change & CHANGED_COLOR)
{
llOwnerSay((string) llGetColor(ALL_SIDES));
}
}
}


drop this script into a prim, now whenever you choose a new color using SL's color picker (in the edit window) it will tell you the vector value, ready for copy out of the chat history and paste into your scripts

besides giving you the full 16 million color spectrum, its alot quicker than digging tru a ginormous list, or doing basic math :)
Rocky Rutabaga
isn't wearing underwear™
Join date: 14 Apr 2006
Posts: 291
03-07-2007 18:08
Thanks for your patience and help (not necessarily in that order.) Here's the script I have.
CODE

default
{
touch_start(integer counter)
{
toggle *= -1; // Here we multiply negative one, to change its
// sign.

if(toggle < 0) // We test to see if it is less than 0, and if it
// is, then we turn on the color changer.
{
llSetTimerEvent(llFrand(variable_delay) + base_delay);
}
else
{
llSetTimerEvent(0);
}
}

timer()
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,ALL_SIDES);
llSetTimerEvent(llFrand(variable_delay) + base_delay);
}
}



So where would I set the RBG coordinates? In the llSetColor? How do I add more than one? I'm truly embarassed by my ignorance. But I do appreciate any pity you can bestow.
Sheridan Otoole
Nomadic Merchant
Join date: 6 Jan 2007
Posts: 9
03-07-2007 18:54
From: Rocky Rutabaga
CODE

timer()
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,ALL_SIDES);
llSetTimerEvent(llFrand(variable_delay) + base_delay);
}
}

So where would I set the RBG coordinates? In the llSetColor? How do I add more than one? I'm truly embarassed by my ignorance. But I do appreciate any pity you can bestow.


The line that sets your color is the one that starts "llColor", but this script has the three-part vector filled by the llFrand function, which picks a random decimal between zero and one. So your script isn't picking from a list of colors you would be able to edit/pick/choose, but is rather casting dice which covers the full 16 million color choices available. If you only want it to choose from a few colors each time is cycles its color, that would need some more intense code rewriting.
_____________________
"Any sufficiently advanced technology is indistinguishable from magic" -- Arthur C. Clarke
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-08-2007 01:46
Try the following

CODE


integer Flag = FALSE;
float variable_delay = 10.;
float base_delay = 5.;

list lColours;

Init()
{


lColours = [ <0.941176,0.972549,1.000000>, // Alice Blue
<0.980392,0.921569,0.843137>, // Antique White
<0.000000,1.000000,1.000000>, // Aqua
<0.498039,1.000000,0.831373>, // Aquamarine
<0.941176,1.000000,1.000000>, // Azure
<0.960784,0.960784,0.862745>, // Beige
<1.000000,0.894118,0.768627>, // Bisque
<0.000000,0.000000,0.000000>, // Black
<1.000000,0.921569,0.803922>, // Blanched Almond
<0.000000,0.000000,1.000000>, // Blue
<0.541176,0.168627,0.886275>, // Blue Violet
<0.647059,0.164706,0.164706>, // Brown
<0.870588,0.721569,0.529412>, // Burly Wood
<0.372549,0.619608,0.627451>, // Cadet Blue
<0.498039,1.000000,0.000000>, // Chartreuse
<0.823529,0.411765,0.117647>, // Chocolate
<1.000000,0.498039,0.313725>, // Coral
<0.392157,0.584314,0.929412>, // Cornflower Blue
<1.000000,0.972549,0.862745>, // Cornsilk
<0.862745,0.078431,0.235294>, // Crimson
<0.000000,1.000000,1.000000>, // Cyan
<0.000000,0.000000,0.545098>, // Dark Blue
<0.000000,0.545098,0.545098>, // Dark Cyan
<0.721569,0.525490,0.043137>, // Dark Golden Rod
<0.662745,0.662745,0.662745>, // Dark Gray
<0.000000,0.392157,0.000000>, // Dark Green
<0.741176,0.717647,0.419608>, // Dark Khaki
<0.545098,0.000000,0.545098>, // Dark Magenta
<0.333333,0.419608,0.184314>, // Dark Olive Green
<1.000000,0.549020,0.000000>, // Dark Orange
<0.600000,0.196078,0.800000>, // Dark Orchid
<0.545098,0.000000,0.000000>, // Dark Red
<0.913725,0.588235,0.478431>, // Dark Salmon
<0.560784,0.737255,0.560784>, // Dark Sea Green
<0.282353,0.239216,0.545098>, // Dark Slate Blue
<0.184314,0.309804,0.309804>, // Dark Slate Gray
<0.000000,0.807843,0.819608>, // Dark Turquoise
<0.580392,0.000000,0.827451>, // Dark Violet
<1.000000,0.078431,0.576471>, // Deep Pink
<0.000000,0.749020,1.000000>, // Deep Sky Blue
<0.411765,0.411765,0.411765>, // Dim Gray
<0.117647,0.564706,1.000000>, // Dodger Blue
<0.819608,0.572549,0.458824>, // Feldspar
<0.698039,0.133333,0.133333>, // Fire Brick
<1.000000,0.980392,0.941176>, // Floral White
<0.133333,0.545098,0.133333>, // Forest Green
<1.000000,0.000000,1.000000>, // Fuchsia
<0.862745,0.862745,0.862745>, // Gainsboro
<0.972549,0.972549,1.000000>, // Ghost White
<1.000000,0.843137,0.000000>, // Gold
<0.854902,0.647059,0.125490>, // Golden Rod
<0.501961,0.501961,0.501961>, // Gray
<0.000000,0.501961,0.000000>, // Green
<0.678431,1.000000,0.184314>, // Green Yellow
<0.941176,1.000000,0.941176>, // Honey Dew
<1.000000,0.411765,0.705882>, // Hot Pink
<0.803922,0.360784,0.360784>, // Indian Red
<0.294118,0.000000,0.509804>, // Indigo
<1.000000,1.000000,0.941176>] + // Ivory
[<0.941176,0.901961,0.549020>, // Khaki
<0.901961,0.901961,0.980392>, // Lavender
<1.000000,0.941176,0.960784>, // Lavender Blush
<0.486275,0.988235,0.000000>, // Lawn Green
<1.000000,0.980392,0.803922>, // Lemon Chiffon
<0.678431,0.847059,0.901961>, // Light Blue
<0.941176,0.501961,0.501961>, // Light Coral
<0.878431,1.000000,1.000000>,// Light Cyan
<0.980392,0.980392,0.823529>, // Light Golden Rod Yellow
<0.827451,0.827451,0.827451>, // Light Grey
<0.564706,0.933333,0.564706>, // Light Green
<1.000000,0.713725,0.756863>, // Light Pink
<1.000000,0.627451,0.478431>, // Light Salmon
<0.125490,0.698039,0.666667>, // Light Sea Green
<0.529412,0.807843,0.980392>, // Light Sky Blue
<0.517647,0.439216,1.000000>, // Light Slate Blue
<0.466667,0.533333,0.600000>, // Light Slate Gray
<0.690196,0.768627,0.870588>, // Light Steel Blue
<1.000000,1.000000,0.878431>, // Light Yellow
<0.000000,1.000000,0.000000>, // Lime
<0.196078,0.803922,0.196078>, // Lime Green
<0.980392,0.941176,0.901961>, // Linen
<1.000000,0.000000,1.000000>, // Magenta
<0.501961,0.000000,0.000000>, // Maroon
<0.400000,0.803922,0.666667>, // Medium Aqua Marine
<0.000000,0.000000,0.803922>, // Medium Blue
<0.729412,0.333333,0.827451>, // Medium Orchid
<0.576471,0.439216,0.847059>, // Medium Purple
<0.235294,0.701961,0.443137>, // Medium Sea Green
<0.482353,0.407843,0.933333>, // Medium Slate Blue
<0.000000,0.980392,0.603922>, // Medium Spring Green
<0.282353,0.819608,0.800000>, // Medium Turquoise
<0.780392,0.082353,0.521569>, // Medium Violet Red
<0.098039,0.098039,0.439216>, // Midnight Blue
<0.960784,1.000000,0.980392>, // Mint Cream
<1.000000,0.894118,0.882353>, // Misty Rose
<1.000000,0.894118,0.709804>, // Moccasin
<1.000000,0.870588,0.678431>, // Navajo White
<0.000000,0.000000,0.501961>, // Navy
<0.992157,0.960784,0.901961>, // Old Lace
<0.501961,0.501961,0.000000>, // Olive
<0.419608,0.556863,0.137255>, // Olive Drab
<1.000000,0.647059,0.000000>, // Orange
<1.000000,0.270588,0.000000>, // Orange Red
<0.854902,0.439216,0.839216>, // Orchid
<0.933333,0.909804,0.666667>, // Pale Golden Rod
<0.596078,0.984314,0.596078>, // Pale Green
<0.686275,0.933333,0.933333>, // Pale Turquoise
<0.847059,0.439216,0.576471>, // Pale Violet Red
<1.000000,0.937255,0.835294>, // Papaya Whip
<1.000000,0.854902,0.725490>, // Peach Puff
<0.803922,0.521569,0.247059>, // Peru
<1.000000,0.752941,0.796078>, // Pink
<0.866667,0.627451,0.866667>, // Plum
<0.690196,0.878431,0.901961>, // Powder Blue
<0.501961,0.000000,0.501961>, // Purple
<1.000000,0.000000,0.000000>, // Red
<0.737255,0.560784,0.560784>, // Rosy Brown
<0.254902,0.411765,0.882353>, // Royal Blue
<0.545098,0.270588,0.074510>]+ // Saddle Brown
[<0.980392,0.501961,0.447059>, // Salmon
<0.956863,0.643137,0.376471>, // Sandy Brown
<0.180392,0.545098,0.341176>, // Sea Green
<1.000000,0.960784,0.933333>, // Sea Shell
<0.627451,0.321569,0.176471>, // Sienna
<0.752941,0.752941,0.752941>, // Silver
<0.529412,0.807843,0.921569>, // Sky Blue
<0.415686,0.352941,0.803922>, // Slate Blue
<0.439216,0.501961,0.564706>, // Slate Gray
<1.000000,0.980392,0.980392>, // Snow
<0.000000,1.000000,0.498039>, // Spring Green
<0.274510,0.509804,0.705882>, // Steel Blue
<0.823529,0.705882,0.549020>, // Tan
<0.000000,0.501961,0.501961>, // Teal
<0.847059,0.749020,0.847059>, // Thistle
<1.000000,0.388235,0.278431>, // Tomato
<0.250980,0.878431,0.815686>, // Turquoise
<0.933333,0.509804,0.933333>, // Violet
<0.815686,0.125490,0.564706>, // Violet Red
<0.960784,0.870588,0.701961>, // Wheat
<1.000000,1.000000,1.000000>, // White
<0.960784,0.960784,0.960784>, // White Smoke
<1.000000,1.000000,0.000000>, // Yellow
<0.603922,0.803922,0.196078>]; // Yellow Green
}



default
{
state_entry()
{
Init();
}

on_rez(integer number) { llResetScript();}

touch_start(integer counter)
{
Flag = ! Flag;
if(Flag)
{
llSetTimerEvent(llFrand(variable_delay) + base_delay);
}
else
{
llSetTimerEvent(0);
}
}

timer()
{
integer max = llGetListLength(lColours);
integer index = (integer)llFrand(max);
vector vcolour = llList2Vector(lColours, index );
llSetColor(vcolour,ALL_SIDES);
llSetTimerEvent(llFrand(variable_delay) + base_delay);
}

}