Miguel Klein
Second Life Resident
Join date: 6 Nov 2004
Posts: 4
|
11-13-2005 21:20
Hi, I am a maker of jewlery and other things, and I am interested in a script where the owner can input their own RGB color in the channel to change the color of the prim(s). Although I've seen scripts with predefined colors that the user can input into the prim, I want the owner to choose whatever color he/she wants.
Thanks!
-Miguel Klein.
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-14-2005 04:48
Well it depends how you'd want to do it, but you could go for something along the lines of: integer val = 255; // Maximum value for a colour
default { state_entry() { llListen(1234,"",llGetOwner(),""); // Change 1234 to the desired channel, something above 100 is usually better } change(integer x) { llResetScript(); } // Something's changed, reset the script for good measure
listen(integer channel, string name, key id, string msg) { if ((channel == 1234) && (id == llGetOwnerId()) { list parts = llParseStringToList(msg,[" "],[]); if (llList2String(parts,0) == "color") { // User wants to change the colour? list parts = llParseStringToList(llList2String(parts,1),[",",", "],[]); // This looks confusing because we're re-using the 'parts' list float x = llList2Float(parts,0) / val; float y = llList2Float(parts,1) / val; float z = llList2Float(parts,2) / val; llSetColor(<x,y,z>,ALL_SIDES); } } } } Now I did this fairly quickly without testing so please point out if anything is wrong! Basically this takes messages of the form: /1234 color 255,127,255 That example giving the colour magenta (full red, full blue). You can easily change the values to be taken as percentages (e.g a value of 0 to 100) or even let them enter the raw numbers (0 to 1) by setting the val variable at the top to 100 or 1 respectively. Hope this helps!
|
Les White
sombish
Join date: 7 Oct 2004
Posts: 163
|
11-14-2005 05:29
colour is normalized so X,Y and Z (RGB) should be floats with values between 0 and 1. <1,1,1> being white. <0,0,0> being black.
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-14-2005 09:14
From: Les White colour is normalized so X,Y and Z (RGB) should be floats with values between 0 and 1. <1,1,1> being white. <0,0,0> being black. be easy to just divide the given values by 255 in the llSetColor vector: llSetColor(<x/255,y/255,z/255>, ALL_SIDES)
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
11-14-2005 09:34
He's already dividing by 255. integer val = 255; // Maximum value for a colour
...
float x = llList2Float(parts,0) / val;
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-14-2005 13:03
Yup, I seperated it in the event that someone would want to use a different max value, like 100 (ie you're entering the percentage of each colour) or 1 (decimal percentage) or 666 (you're an evil person) etc. etc. =)
|
Miguel Klein
Second Life Resident
Join date: 6 Nov 2004
Posts: 4
|
11-14-2005 17:53
I get a syntax error when I paste it in 
|