Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Color Changer Madness?

Esquievel Easterwood
Deer in the headlights
Join date: 25 Oct 2008
Posts: 220
12-06-2009 14:43
I have a box prim, blank texture. Color of all sides is set to RGB 128,0,0 (dark red).

I want to make it alternate between that color and a light pink (RGB 255,128,128).

I use the following script. The output says that the colors are being set as I want. However, on both the prim and the color picker (which I have open as it runs), the "bright color" is white (255,255,255), and the "dark color" is a bright red (255,0,0). I'm testing this at midday, with no light source nearby, and Full Bright off. Script appears below. Can anyone explain this?

Thanks.

// NOTE: It doesn't matter whether I include the call to llSetPrimitiveParams() or not;
// behavior is the same.
vector curcol = <0,0,0>;

default
{
state_entry()
{
llSetTimerEvent(1);
}

timer()
{
// Make it "bright".
llSetColor(<255.0, 128.0, 128.0>,ALL_SIDES);
llSleep(2);
list lightParams = [ PRIM_POINT_LIGHT,
TRUE,
<1, 1, 1>,
1.0,
10.0,
0.75];

llSetPrimitiveParams( lightParams );
curcol = llGetColor(ALL_SIDES);

llSay(0,"Color is " + (string)curcol);

llSleep (1.0);

// Make it "dark".
llSetColor (<128.0, 0.0, 0.0>,ALL_SIDES);
llSleep(2);

list lightParamsOff = [ PRIM_POINT_LIGHT,
FALSE,
<0.5, 0.5, 0.5>,
1.0,
10.0,
0.75];

llSetPrimitiveParams( lightParamsOff );

curcol = llGetColor(ALL_SIDES);

llSay(0,"Color is " + (string)curcol);
}
}
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
12-06-2009 15:06
Scripts use a value of 0.0 to 1.0 to specify the RGB components of a colour; 1.0 is the equivalent of 255, 0.5 the equivalent of 127. If you use a value greater than 1.0 it gets "truncated" to 1.0.
Esquievel Easterwood
Deer in the headlights
Join date: 25 Oct 2008
Posts: 220
12-06-2009 16:10
From: Pete Olihenge
Scripts use a value of 0.0 to 1.0 to specify the RGB components of a colour; 1.0 is the equivalent of 255, 0.5 the equivalent of 127. If you use a value greater than 1.0 it gets "truncated" to 1.0.
Thanks! But does that mean I have to do a proportional calculation to translate "real" RGB values to these decimal values?

I mean, if I have a green at RGB 147,251,137, can I use:

0.147,0.251,0.137

or do I have to do:

147/255 = x/1 = 0.576
251/255 = x/1 = 0.984
137/255 = x/1 = 0.537

?

Thanks.
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
12-06-2009 16:25
From: Esquievel Easterwood
147/255 = x/1 = 0.576
251/255 = x/1 = 0.984
137/255 = x/1 = 0.537
Yeah, like that. I fell into that trap too, first time I tried.
Esquievel Easterwood
Deer in the headlights
Join date: 25 Oct 2008
Posts: 220
12-06-2009 17:05
Thanks so much.

Next question: Is there any way to preserve the original color value of the prim no matter what state it's in when the script stops running?

Right now I have the script reading the RGB value from a notecard in the prim. I'd rather not do that if there's another way to preserve it. If that's the only way, then can I cause the script to write the original color to a blank notecard the first time it runs?

The idea is to be able to simply manually set or change color of the prim, drop the script in without having to modify it, and have it all work.

Thanks.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-06-2009 20:13
can't write to notecards, but you can either use a preset value in the script, or write it in a prim property like the description field.

since you need it to read and save the starting value, I'd go with the second method.

I've also made a multiprim color changer that's on the lsl Portal, color matches all prims with the same name as the prim it's in http://wiki.secondlife.com/wiki/User:Void_Singer/Programs#v7-D_Enh._Color_Picker

feel free to use it, or to see how I went about it to get ideas for your own project
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Esquievel Easterwood
Deer in the headlights
Join date: 25 Oct 2008
Posts: 220
12-06-2009 21:37
From: Void Singer
can't write to notecards, but you can either use a preset value in the script, or write it in a prim property like the description field.

since you need it to read and save the starting value, I'd go with the second method.

I've also made a multiprim color changer that's on the lsl Portal, color matches all prims with the same name as the prim it's in http://wiki.secondlife.com/wiki/User:Void_Singer/Programs#v7-D_Enh._Color_Picker

feel free to use it, or to see how I went about it to get ideas for your own project
Thanks very much. I was just hoping to be able to have a script that could work off the prim's color without having to set any other properties. I will study your script though, and I appreciate your help.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-06-2009 21:59
the basic idea for saving script data outside a script (to survive resets):

script starts, checks description field....
if description contains a color use that,
else get current color and store it in the description.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -