Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Color v7D_Enh_Color_Picker__V11  

v7D_Enh_Color_Picker__V11

v7D_Enh_Color_Picker__V11

Category: Color
By : Void Singer
Created: 2010-02-01 Edited: 2010-02-01
Worlds: Second Life

the Zip file

Download all files for v7D_Enh_Color_Picker__V11
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. v7D_Enh_Color_Picker__V11_1.lsl
1 /*//( v7-D Enh. Color Picker v1.2 )//*/
2
3 /*//-- IMPORTANT NOTE
4 This Script MUST be
5 placed in one of the
6 prims it is going to
7 modify or it will not
8 work properly!
9
10 All Prims that are to
11 be modified at the
12 same time MUST have
13 the SAME NAME !!!
14 //*/
15
16 key gKeyOwner;
17 integer gIdxPanel;
18 integer gChnDialog;
19 list gLstTargets;
20 integer gIntTargets;
21 vector gColDefault = <0.0, 0.0, 0.0>;
22 string gStrProduct = "v7-D Adv Color Picker v1.2";
23 list gLstButtons = ["-1", "-8", "-64", "+1", "+8", "+64",
24 "Recall", "Done!", "Save",
25 "All Colors", "Red Only", "Green Only", "Blue Only"];
26 list gLstBValues = [-0.003922, -0.031373, -0.250980, 0.003922, 0.031373, 0.250980,
27 <1.0, 1.0, 1.0>, <1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>];
28
29
30 fColorDialog(){
31 vector vColTemp = llGetColor( ALL_SIDES ) * 255;
32 //-- build the dialog to send
33 llDialog( gKeyOwner,
34 gStrProduct + "\n\nModifying "
35 + llList2String( gLstButtons, gIdxPanel )
36 + "\n\nCurrent Values (0-255):\n"
37 + "R:" + (string)llRound( vColTemp.x )
38 + ", G:" + (string)llRound( vColTemp.y )
39 + ", B:" + (string)llRound( vColTemp.z )
40 + " = #" + fFloat2HexStr( vColTemp.x )
41 + fFloat2HexStr( vColTemp.y )
42 + fFloat2HexStr( vColTemp.x ),
43 llDeleteSubList( gLstButtons, gIdxPanel, gIdxPanel ),
44 gChnDialog );
45 llSetTimerEvent( 45.0 );
46 }
47
48 string fFloat2HexStr( float vFltInput ){
49 integer vBitInput = llRound( vFltInput );
50 string vStrValue = "0123456789ABCDEF";
51 return llGetSubString( vStrValue, gIntTargets = vBitInput / 16, gIntTargets )
52 + llGetSubString( vStrValue, gIntTargets = vBitInput % 16, gIntTargets );
53 }
54
55 fSetColor( vector vColUse ){
56 //-- loop through target list of linked prims
57 gIntTargets = gLstTargets != [];
58 @Loop;
59 llSetLinkColor( llList2Integer( gLstTargets, --gIntTargets ), vColUse, ALL_SIDES );
60 if(gIntTargets) jump Loop;
61 }
62
63
64 default{
66 gKeyOwner = llGetOwner();
67 gChnDialog = (integer)("0xF" + llGetSubString( gKeyOwner, 1, 7 ));
68
69 string vStrTargetID = llGetObjectName();
70 gIntTargets = llGetNumberOfPrims();
71 @Loop;
72 if(llGetLinkName( gIntTargets ) == vStrTargetID){
73 gLstTargets += (list)gIntTargets;
74 }
75 if(~(--gIntTargets)) jump Loop;
76 state sReady;
77 }
78
79 changed( integer vBitChanges ){
80 if((CHANGED_OWNER | CHANGED_LINK) & vBitChanges){
82 }
83 }
84 }
85
86 state sReady{
88 gIdxPanel = 9;
89 }
90
91 touch_end( integer vIntTotal ){
92 if(llDetectedKey( 0 ) == gKeyOwner){
93 state sRunning;
94 }
95 }
96
97 changed( integer vBitChanges ){
98 if((CHANGED_OWNER | CHANGED_LINK) & vBitChanges){
99 state default;
100 }
101 }
102 }
103
104
105 state sRunning{
107 llListen( gChnDialog, "", gKeyOwner, "" );
108 fColorDialog();
109 }
110
111 listen( integer vIntChannel, string vStrName, key vKeySpeaker, string vStrHeard ){
112 //-- get the index of the reply from our button list
113 integer vIdxReply = llListFindList( gLstButtons, (list)vStrHeard );
114 //-- is it a valid index? ~(-1) = FALSE
115 if(~vIdxReply){
116 //-- reply index 0 -5
117 if(6 > vIdxReply){
118 //-- get current color add change amount form dialog
119 vector vColCalc = llGetColor( ALL_SIDES )
120 + llList2Vector( gLstBValues, gIdxPanel - 3 )
121 * llList2Float( gLstBValues, vIdxReply );
122 //-- Clamp color values to [0, 1]
123
124 // change by fkb 1/10/2013
125 float a = (integer) (0.0 < vColCalc.x && vColCalc.x < 1.0) * vColCalc.x;
126 float b = (integer) (0.0 < vColCalc.y && vColCalc.y < 1.0) * vColCalc.y;
127 float c = (integer) (0.0 < vColCalc.z && vColCalc.z < 1.0) * vColCalc.z;
128
129 integer d = (vColCalc.x >= 1.0);
130 integer e = (vColCalc.y >= 1.0);
131 integer f = (vColCalc.z >= 1.0);
132
133
134
135 fSetColor( <a,b,c> + <d,e,f> );
136
137
138 // fSetColor( <(0.0 < vColCalc.x && vColCalc.x < 1.0) * vColCalc.x,
139 // (0.0 < vColCalc.y && vColCalc.y < 1.0) * vColCalc.y,
140 // (0.0 < vColCalc.z && vColCalc.z < 1.0) * vColCalc.z>
141 // + <(vColCalc.x >= 1.0),
142 // (vColCalc.y >= 1.0),
143 // (vColCalc.z >= 1.0)> );
144
145 //-- reply index 6-8
146 }else if(9 > vIdxReply){
147 //-- Apply Saved Color
148 if(6 == vIdxReply){
149 fSetColor( gColDefault );
150 //-- done, go back to waiting
151 }else if(7 == vIdxReply){
152 llSetTimerEvent( 0.0 );
153 state sReady;
154 //-- save current color
155 }else{
156 gColDefault = llGetColor( ALL_SIDES );
157 llWhisper( 0, "Color saved." );
158 }
159 //-- reply index 9-12
160 }else if(13 > vIdxReply){
161 //-- change dialog panel
162 gIdxPanel = vIdxReply;
163 }
164 fColorDialog();
165 }
166 }
167
168 timer(){
169 //-- timeout to kill listens
170 llSetTimerEvent( 0.0 );
171 llOwnerSay( gStrProduct + " Dialog Timed Out." );
172 state sReady;
173 }
174
175 changed( integer vBitChanges ){
176 if((CHANGED_OWNER | CHANGED_LINK) & vBitChanges){
177 state default;
178 }
179 }
180 }
181
182 /*//-- License Text --//*/
183 /*// Free to copy, use, modify, distribute, or sell, with attribution. //*/
184 /*// (C)2009 (CC-BY) [ http://creativecommons.org/licenses/by/3.0 ] //*/
185 /*// Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ] //*/
186 /*// All usages must contain a plain text copy of the previous 2 lines. //*/
187 /*//-- --//*/

Back to the Best Free Tools in Second Life and OpenSim.