CODE
// LSL Paint Shop Script
// Copyright (C) 2007 Brandon Chandler & James Morgan
// Created by: Brandon Chandler
// Original by: Brandon Chandler
// Created: 12-20-06
// Last Updated: 12-24-06
//
//
//--------------------Notes
// This script is intended to facilitate easier control of color
// within Second Life. I ask that if you make any changes to this script,
// please send a copy of your work along with a description of your improvements
// to Brandon Chandler.
//
//
//--------------------License
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Also available at http://www.gnu.org/copyleft/gpl.html
//
//
//--------------------Support
// If you encounter any problems with LSL Paint Shop please instant message
// Brandon Chandler. Please try to be specific about the problem and what you did
// leading up to it. If I can't reproduce it, I can't fix it. If there is
// indeed a problem,that can be found, I will fix it as soon as possible.
// I do not guarantee to support this script or any modifications of this script.
//
//
//--------------------Features
// - Supports 16 basic colors presets.
// - Supports custom color creation, over 1300 different colors.
// - Supports easy navigation menu system.
// - Supports multipule prim selection.
// - Supports flood fill over entire link set.
//
//
//--------------------Credits
// I would like to thank the following for inspiration.
// Alex Drago
// Cid Jacobs
// Torley Linden
// I would like to thank the following for aplha testing.
// Cid Jacobs
// Jeff Beckenbauer
// Marious Bishop
// I would like to thank the following for beta testing.
// Cid Jacobs
// Jeff Beckenbauer
// Marious Bishop
// Neural Blankes
//
//
//--------------------Change Log
//V0.1.0
// - Clarified Text
//V0.0.9
// - Clarified Text
//V0.0.8
// - Additional Colors Added
// - More Precise Color Vectors
//V0.0.7
// - "Prev" Button Added
//V0.0.6
// - "Next" Button Added
//V0.0.5
// - Additional Colors Added
//V0.0.4
// - Clarified Text
// - Multi-Prim Deselection
//V0.0.3
// - Multi-Prim Selection and Coloring Enabled
//V0.0.2
// - Single Prim Selection and Coloring Enabled
//V0.0.1
// - Color Link Set from One Script
//
//
//--------------------Globals
//Stores "Fill All" Selection Toggle
integer All = FALSE;
//Temporarily Stores Detected Link Number
integer DLN;
//Stores Exit Value for Dialog Events
integer Exit = FALSE;
//Stores Global Listener Value
integer Listener = FALSE;
//Temporarily Stores Count Value for DNL List
integer i;
//Temporarily Stores Count Value for Color Selection
integer Test;
//Stores User Place in Dialog
integer Place = 0;
//Tempoarily Stores Random Channel
integer Random_Channel = 0;
//Stores Predefined Colors and Tools
list Colors = [
"Royal Blue",
"Violet",
"Next",
"Blue",
"Green",
"Select +/-",
"Blue Green",
"Gray",
"Fill All",
"Black",
"White",
"Custom"
];
//Stores Predefined Colors and Tools
list Colors2 = [
"Brown",
"Gold",
"Prev",
"Orange",
"Yellow",
"Select +/-",
"Red Violet",
"Pink",
"Fill All",
"Red",
"Red Orange",
"Custom"
];
//Stores Predefined Colors Vectors
list ColorsVector = [
<0.04314, 0.33725, 0.71765>,
<0.43529, 0.34902, 0.63922>,
<1.00000, 1.00000, 1.00000>,
<0.00000, 0.40000, 1.00000>,
<0.00392, 0.63922, 0.40784>,
<1.00000, 1.00000, 1.00000>,
<0.00000, 0.58431, 0.71373>,
<0.54510, 0.52549, 0.50196>,
<1.00000, 1.00000, 1.00000>,
<0.00000, 0.00000, 0.00000>,
<1.00000, 1.00000, 1.00000>,
<1.00000, 1.00000, 1.00000>
];
//Stores Predefined Colors Vectors
list Colors2Vector =[
<0.70196, 0.34118, 0.22745>,
<1.00000, 0.68235, 0.25882>,
<1.00000, 1.00000, 1.00000>,
<1.00000, 0.40784, 0.12157>,
<0.98431, 0.90980, 0.43922>,
<1.00000, 1.00000, 1.00000>,
<0.73333, 0.20000, 0.52157>,
<1.00000, 0.65098, 0.78824>,
<1.00000, 1.00000, 1.00000>,
<0.92941, 0.03922, 0.24706>,
<1.00000, 0.24706, 0.20392>,
<1.00000, 1.00000, 1.00000>
];
//Stores Custom Options
list Custom = [
"0.8",
"0.9",
"1.0",
"0.5",
"0.6",
"0.7",
"0.2",
"0.3",
"0.4",
"0.0",
"0.1"
];
//Stores Detected Link Numbers for "Add Selection" Feature
list LNL;
//Stores Color Vector
vector Color = <1,1,1>;
//
//
//--------------------States
//Required Default State
default
{
//Triggered on Agent Touching
touch_start(integer total_number)
{
//Filter Touch for Owner Touch
if(llDetectedKey(0) == llGetOwner())
{
//Store Detected Link Number
DLN = llDetectedLinkNumber(0);
//Store Place in Dialog
Place = -1;
//Remove Extraneous Listens
llListenRemove(Listener);
//Create and Store Random Communication Channel
Random_Channel = 10 + (integer)llFrand(100000);
//Create and Store Custom Listen
Listener = llListen(Random_Channel,"",llGetOwner(),"");
//Stat Timer Event
llSetTimerEvent(120.0);
//Dialog Owner with Colors and Options
llDialog(llGetOwner(),"Select a Pallet Color:",Colors,Random_Channel);
}
}
//Result of Listen Library Call
listen(integer chan, string name, key id, string msg)
{
//Compare Channel and Stored Random Channel
if(chan == Random_Channel)
{
//Compare Dialog Entrance
if(Place == -1)
{
//Return Start of Fist Instance of DLN in LNL List
integer LinkList = llListFindList(LNL,(list)DLN);
//If DLN Not Found in LNL
if(LinkList == -1)
{
//Add DLN to LNL
LNL += DLN;
}
//If DLN Found in LNL
else
{
//Remove DLN from LNL
LNL = llDeleteSubList(LNL,LinkList,LinkList);
}
//Increase Dialog Entrance Point
Place = 0;
}
//First Dialog Entrance
if((Place == 0)|(Place == 4))
{
//Set Timer Event
llSetTimerEvent(120.0);
//Compare Dialog Entrance Value
if(Place == 0)
{
//Return Start of Fist Instance of Message in Colors List
Test = llListFindList(Colors,(list)msg);
}
//Compare Dialog Entrance Value
if(Place == 4)
{
//Return Start of Fist Instance of Message in Colors List
Test = llListFindList(Colors2,(list)msg);
}
//If Message Found in Color List
if(Test != -1)
{
//Compare Dialog Entrance Value
if(Place == 0)
{
//Check Test Value
if((Test == 0)|
(Test == 1)|
(Test == 3)|
(Test == 4)|
(Test == 6)|
(Test == 7)|
(Test == 9)|
(Test == 10))
{
//Store Color Value From Vector List
Color = llList2Vector(ColorsVector,Test);
}
//Data Tree Has Not Ended
else
{
// If we select "Next"
if(Test == 2)
{
//Increase Dialog Entrance Point
Place = 4;
//Dialog Owner With Extended Color Option List
llDialog(llGetOwner(),"SSelect a Pallet Color:",Colors2,Random_Channel);
//Leave Current Event
return;
}
// If we select "Add Selection"
else if(Test == 5)
{
//Increase Dialog Entrance Point
Place = -1;
//Leave Current Event
return;
}
// If we select "Fill All"
else if(Test == 8)
{
//Toggle "Fill All" Value
All = !All;
}
// If we select "Custom"
else if(Test == 11)
{
//Increase Dialog Entrance Point
Place = 1;
//Dialog Owner With Red Custom Color Option List
llDialog(llGetOwner(),"Paint Mix Mode.
Choose a value for Red (Second Life RGB).",Custom,Random_Channel);
//Leave Current Event
return;
}
}
}
//Compare Dialog Entrance Value
else if(Place == 4)
{
//Check Test Value
if((Test == 0)|
(Test == 1)|
(Test == 3)|
(Test == 4)|
(Test == 6)|
(Test == 7)|
(Test == 9)|
(Test == 10))
{
//Store Color Value From Vector List
Color = llList2Vector(Colors2Vector,Test);
}
// If we select "Fill All"
else if(Test == 8)
{
//Toggle "Fill All" Value
All = !All;
}
// If we select "Custom"
else if(Test == 11)
{
//Increase Dialog Entrance Point
Place = 1;
//Dialog Owner With Red Custom Color Option List
llDialog(llGetOwner(),"Paint Mix Mode.
Choose a value for Red (Second Life RGB).",Custom,Random_Channel);
//Leave Current Event
return;
}
//Data Tree Has Not Ended
else
{
// If we select "Prev"
if(Test == 2)
{
//Increase Dialog Entrance Point
Place = 0;
//Dialog Owner With Extended Color Option List
llDialog(llGetOwner(),"Select a Pallet Color:",Colors,Random_Channel);
//Leave Current Event
return;
}
// If we select "Add Selection"
else if(Test == 5)
{
//Increase Dialog Entrance Point
Place = -1;
//Leave Current Event
return;
}
}
}
//Increase Dialog Entrance Point
Place = 1;
//If "Fill All" Selected
if(All == TRUE)
{
//Set Link Color to Selected Color
llSetLinkColor(LINK_SET,Color,ALL_SIDES);
}
//If "Fill All" Not Selected
else
{
//For Loop For Coloring Individual Prims From LNL
for(i = 0;i <= llGetListLength(LNL);i++)
{
//Set Link Color For Individual Prims
llSetLinkColor(llList2Integer(LNL,i),Color,ALL_SIDES);
}
}
//Store Exit Value
Exit = TRUE;
//Set Timer Event
llSetTimerEvent(0.1);
//Leave Current Event
return;
}
}
//Second Dialog Entrance
else if(Place == 1)
{
//Set Timer Event
llSetTimerEvent(120.0);
//Increase Place in Dialog
Place = 2;
//Store Red Custom Color Value
Color.x = (float)msg;
//Dialog Owner With Custom Green Value Option
llDialog(llGetOwner(),"Paint Mix Mode.
Choose a value for Green (Second Life RGB).",Custom,Random_Channel);
//Leave Current Event
return;
}
//Third Dialog Entrance
else if(Place == 2)
{
//Set Timer Event
llSetTimerEvent(120.0);
//Increase Place in Dialog
Place = 3;
//Store Green Custom Color Value
Color.y = (float)msg;
//Dialog Owner With Custom Blue Color Option
llDialog(llGetOwner(),"Paint Mix Mode.
Choose a value for Blue (Second Life RGB).",Custom,Random_Channel);
//Leave Current Event
return;
}
//Fourth Dialog Entrance
else if(Place == 3)
{
//Set Timer Event
llSetTimerEvent(120.0);
//Increase Place in Dialog
Place = 4;
//Store Blue Custom Color Value
Color.z = (float)msg;
//If "Fill All" Selected
if(All == TRUE)
{
//Set Link Color to Selected Custom Color
llSetLinkColor(LINK_SET,Color,ALL_SIDES);
}
//If "Fill All" Not Selected
else
{
//For Loop For Coloring Individual Prims From LNL
for(i = 0;i <= llGetListLength(LNL);i++)
{
//Set Link Color For Individual Prims From LNL
llSetLinkColor(llList2Integer(LNL,i),Color,ALL_SIDES);
}
}
//Set Exit Value
Exit = TRUE;
//Set Timer Event
llSetTimerEvent(0.1);
//Leave Current Function
return;
}
}
}
//Result of Timer Library Call
timer()
{
//End Timer Event Call
llSetTimerEvent(0.0);
//Clear Stored LNL
LNL = llDeleteSubList(LNL,0,-1);
//Reset "Fill All" Toggle
All = FALSE;
//Clear Place Value
Place = -1;
//Exit Value is FALSE
if(Exit == FALSE)
{
//Check List Length of LNL
if(llGetListLength(LNL) > 0)
{
//Notify Owner of Listen Expiration
llOwnerSay("Timer Expired. Please try again.");
}
}
//Remove Stored Listen
llListenRemove(Listener);
}
}