Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Tint and Texture Windows

Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
03-05-2008 07:01
Having looked up a number of the window control scripts, none did quite what I wanted, so a great chance for my firts real fling at LSL. The following scriptsare the result. Basically this is your standard window tinter, with a couple of twists:

1) Allows multiple windows, as many as you want
2) Select to change the tint on the outside or inside of the window
3) When a window is tinted 100% a texture is used instead

The scripts posted are:

TintController - goes in the prim to be used as the contoller
TargetWindow - goes in the windows to be controlled
WindowFace - since the control of inside and outside is based on particular faces of the prim, this script helps you see which side is which during building.

Hope these are useful!

-----------------
//
CODE

// Window Tint Controller Script (put into controller prim)
//
// *******************************************************************
// This program is free software; you can redistribute it and/or
// modify as you wish. Just don't try and sell it to someone ...
// that would not be nice or fair.
// If you have paid someone for this script .. contact me and we'll
// track them down inworld and harass them ;-)
//
// While I do not offer support for this script if you have questions
// feel free to contact me inworld.
//
// Writen by Shifting Dreamscape
// *******************************************************************


//The % to Tint the window
list TINT_OPTIONS = ["40%", "20%", "None", "100%", "80%", "60%"];

//List as many options as windows that you have to tint
list WINDOW_OPTIONS = ["Window Title1", "All"];

//For each option, ending the list with a 0 for All, set up a list of channels.
//These should be large negative numbers, example would be starting at -30000
//and continuing up from there
list WINDOW_CHANNELS = [-30000,0];

//Side of the Window to Tint
list SIDE_OPTIONS = ["Outside", "Inside", "Both"];

//Dialog Channel to listen on
integer LISTEN_CHAN = -29999;

//Identifiers for the different dialog boxes
integer NO_DIALOG = 0;
integer CHECK_WINDOW = 1;
integer CHECK_TINT = 2;
integer CHECK_SIDE = 3;

//Variable set when a window is chosen
string winSelected;
//Holds the Tint level Chosen
string msgTint;

//Holds the side to tint .. will be changed to a digit:
//both = ALL_SIDES (face constant)
//The others are based on the window sides being along the y axis ..
//Use the windowFace script to determine which these are
integer OUT_SIDE = 1; //-y axis
integer IN_SIDE = 3; //+y axis
string sideModifier;

//Holds which Dialog was last shown
integer curDialog;


default
{
state_entry()
{
llListen(LISTEN_CHAN, "", NULL_KEY, "");
} // end state_entry()


touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "Which window would you like to tint?", WINDOW_OPTIONS, LISTEN_CHAN);
curDialog = CHECK_WINDOW;
} // end touch_start()


listen(integer channel, string name, key id, string message)
{
//Check that we are getting one of the possible options
if (llListFindList(TINT_OPTIONS + WINDOW_OPTIONS + SIDE_OPTIONS, [message]) != -1)
{
//Hold the window selected and show the next Dialog
if (curDialog == CHECK_WINDOW)
{
//Hold the option selected
winSelected = message;

//Now Ask for the Tint .. setting the the proper dialog
curDialog = CHECK_TINT;
llDialog(id, "How much tint would you like?", TINT_OPTIONS, LISTEN_CHAN);
}
else if (curDialog == CHECK_TINT)
{

//Change the message into a number and hold it
if (message == "None")
{
msgTint = "0";
}
else
{
msgTint = llGetSubString(message, 0, llStringLength(message)-2);
}

//Set Next Dialog and show
curDialog = CHECK_SIDE;
llDialog(id, "Which sides would you like to tint?", SIDE_OPTIONS, LISTEN_CHAN);
}
else if (curDialog == CHECK_SIDE)
{
integer i = 0;
integer quit = 0;
integer listLen = llGetListLength(WINDOW_CHANNELS);

//Now we start tinting!!!
curDialog = NO_DIALOG;

//First set our side modifier based on the side chosen
//Default is Both
if (message == "Inside")
{
sideModifier = (string)IN_SIDE;
}
else if (message == "Outside")
{
sideModifier = (string)OUT_SIDE;
}
else
{
sideModifier = (string)ALL_SIDES;
}

//Now call the windows
while (quit == 0 && i < listLen-1)
{
if (llList2String(WINDOW_OPTIONS, i) == winSelected || winSelected == "All")
{
llSay(llList2Integer(WINDOW_CHANNELS,i), msgTint + "@" + sideModifier);
if (winSelected != "All")
{
quit = 1;
}
}
i++;
}
}
}
} // end listen
} // end default
//


--------------

//
CODE

// Window Tint target Script (put into the window prim)
//
// When a window is set to 100% this will replace the texture based on
// the texture you have assigned below. This allows for blinds,
// mirrored look, or anything else you might want.
//
// If you change the texture or color of the window after dropping
// in this script, be sure to reset or these will be lost
//
// *******************************************************************
// This program is free software; you can redistribute it and/or
// modify as you wish. Just don't try and sell it to someone ...
// that would not be nice or fair.
// If you have paid someone for this script .. contact me and we'll
// track them down inworld and harass them ;-)
//
// While I do not offer support for this script if you have questions
// feel free to contact me inworld.
//
// Writen by Shifting Dreamscape
// *******************************************************************


//Channel to listen to ... based on the value assigned in the controller for this window
integer LISTEN_CHAN = -30000;

//Side constants
integer OUT_SIDE = 1; //-y axis
integer IN_SIDE = 3; //+y axis

//The Inner/Outer Texture when at 100%. The default here is a set of blinds
string IN_TEXT = "d31e1d9d-2f33-64be-0642-655de5e9d001";
string OUT_TEXT = "d31e1d9d-2f33-64be-0642-655de5e9d001";

//Color for the window when the texture is set, default is white but can be changed to anything
vector TEXT_COLOR = <1.0, 1.0, 1.0>;

//Holds the original color of the window sides
vector baseInColor;
vector baseOutColor;

//Holds the original texture
string baseInText;
string baseOutText;

default
{
state_entry()
{
llListen(LISTEN_CHAN, "", NULL_KEY, "" );

//Save the base colors & textures
baseInColor = llGetColor(IN_SIDE);
baseOutColor = llGetColor(OUT_SIDE);
baseInText = llGetTexture(IN_SIDE);
baseOutText = llGetTexture(OUT_SIDE);

}//End state_entry

listen(integer channel, string name, key id, string message)
{
list listValues;
float tintValue;
integer sideToTint;

//Need to split out the side and tint values
listValues = llParseString2List(message,["@"],[""]);

//get the tintValue
tintValue = llList2Float(listValues,0)/100;

//now the side value
sideToTint = llList2Integer(listValues,1);

//Set the Alpha
llSetAlpha(tintValue, sideToTint);

//Now if this is 100% we need to change the color to white and set the texture
if (tintValue == 1)
{
if (sideToTint != OUT_SIDE)
{
llSetColor(TEXT_COLOR, IN_SIDE);
llSetTexture(IN_TEXT, IN_SIDE);
}
if (sideToTint != IN_SIDE)
{
llSetColor(TEXT_COLOR, OUT_SIDE);
llSetTexture(OUT_TEXT, OUT_SIDE);
}
}
//Otherwise we need to reset to the original color and texture
else
{

if (sideToTint != OUT_SIDE)
{
llSetColor(baseInColor, IN_SIDE);
llSetTexture(baseInText, IN_SIDE);
}

if (sideToTint != IN_SIDE)
{
llSetColor(baseOutColor, OUT_SIDE);
llSetTexture(baseOutText, OUT_SIDE);
}
}

}//End Listen
}//End Default
//


---------------

//
CODE

// WindowFace Identifier
//
// Sets a texture on the inside and outside faces of a prim so
// that you can identify these when placing the window.
//
// If you change the texture or color of the window after dropping
// in this script, be sure to reset or these will be lost
//
// Just touch the window to swap between the id textures and the originals
//
// Don't forget to remove this script when you are done
//
// *******************************************************************
// This program is free software; you can redistribute it and/or
// modify as you wish. Just don't try and sell it to someone ...
// that would not be nice or fair.
// If you have paid someone for this script .. contact me and we'll
// track them down inworld and harass them ;-)
//
// While I do not offer support for this script if you have questions
// feel free to contact me inworld.
//
// Writen by Shifting Dreamscape
// *******************************************************************

//Side constants
integer OUT_SIDE = 1; //-y axis
integer IN_SIDE = 3; //+y axis

//Current Texture Constants
integer TEXT_ORIG = 0;
integer TEXT_ID = 1;

//Color for the window when the id texture is set
vector WHITE =<1.0, 1.0, 1.0>;

//The Identifier Textures
string ID_OUT_TEXT = "6d18a282-34c7-27d8-4c96-b0904304ac69";
string ID_IN_TEXT = "114a8958-5f3f-8c6d-1ba7-f26f77ed15b1";

//Holds the original color of the window sides
vector baseInColor;
vector baseOutColor;

//Holds the original texture
string baseInText;
string baseOutText;

//Flag as to which is shown
// 0 = Original
// 1 = Id
integer curText;

default
{
state_entry()
{
//Get the original colors and textures
baseInColor = llGetColor(IN_SIDE);
baseOutColor = llGetColor(OUT_SIDE);
baseInText = llGetTexture(IN_SIDE);
baseOutText = llGetTexture(OUT_SIDE);

curText = TEXT_ORIG;

}//End state_entry

touch_start(integer total_number)
{
if (curText == TEXT_ORIG)
{
llSetColor(WHITE, IN_SIDE);
llSetColor(WHITE, OUT_SIDE);
llSetTexture(ID_IN_TEXT, IN_SIDE);
llSetTexture(ID_OUT_TEXT, OUT_SIDE);
curText = TEXT_ID;
}
else
{
llSetColor(baseInColor, IN_SIDE);
llSetColor(baseOutColor, OUT_SIDE);
llSetTexture(baseInText, IN_SIDE);
llSetTexture(baseOutText, OUT_SIDE);
curText = TEXT_ORIG;
}

} // end touch_start()

}//End Default
//
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
03-12-2008 19:35
:)
_____________________
i've got nothing. ;)
Kali Emmons
Registered User
Join date: 14 Mar 2007
Posts: 12
04-06-2008 04:30
Hi..... First I think its great you folk understand these script things and thank you for sharing them. But... question.....

WHO can control the tint controller??

For example... I want it so only one or two people (the residents of the house) can alter the tint... not anyone who happens to come along and want to mess with the tint level.

I saw a "freebie" tint controller set.... it worked by putting a "key" in the description field of the properties of each window (together with the tint script) .... but it appears only one person...the person who added the script to the window... can alter the tint from the controller. (The "key" was given initially when you first rez the controller).

ty

Kal

PS Sharing the controler or window with the group (deeing it even) didnt make any difference in as such only the owner of the controller/windows could alter the tint).
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-22-2008 05:54
Kali ... just saw you post here. Good point and one I have worked on in my next generation controller. apart from changes to use linked messages I have added in a check against a list of users so that only 'authorized users' can access the tint control. IM me inworld and I can get you the scripts that I have set up (still in beta so not published here yet).
JaneD DeCuir
Registered User
Join date: 4 Jun 2008
Posts: 35
axis vs. rezzing
08-07-2008 22:58
An interesting point is how to change the axis where the script does set the tint. Ive tried to change the faces but the script does always show the textures on any second prim wrong. I guess its a thing of its axis but my windows on my builds are anytime oriented that face zero and face five are the outer and inner window. Any hints to me what it depends with the axis - i guess when i change the x or y axis the tinter is able to count which side of the prim it exactly has to change.
And remember that when you put the tinter together with a rez-script into a prim the prim must be at 0 0 0 or the rezzer will have troubles after to orient the prelinked prims. Otherwise it will not work well!
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
08-09-2008 17:59
Jane ... not sure what your getting at. Never have tried this with a rezzer so don't know what you mena. An truth is I'm not sure if I ever have tried with a window that was not flush to the world axis ... but ... as far as I know the face of a prim has nothing to do with the axis, it is a property inherent in the prim. Actually that is why you need to see which face is which for these scripts.

To see what I mean ... take a prim and put the face id script in it ... tinting one side to a different color so you can keep track. Now click to see the sides ... after clicking again rotate the prim as you wish. Clicking again should show that the face with the color has folowed the rotation.
VonGklugelstein Alter
Bedah Profeshinal Tekstur
Join date: 22 Dec 2007
Posts: 808
01-19-2009 15:10
I have a question regarding this:

Is there a way to process transparancy changes only from 75-100% and then have the texture change when the tint value is received in the range from 0-74% and have that trigger the texture change?

Some things do not look good when they are see through.

Also I noticed that this script is very damaging to the original texture while setting up. It is hard not to lose it because any script reset will kill the memory of the original textures.

Thanks


From: Shifting Dreamscape

//Channel to listen to ... based on the value assigned in the controller for this window
integer LISTEN_CHAN = -30000;

//Side constants
integer OUT_SIDE = 1; //-y axis
integer IN_SIDE = 3; //+y axis

//The Inner/Outer Texture when at 100%. The default here is a set of blinds
string IN_TEXT = "d31e1d9d-2f33-64be-0642-655de5e9d001";
string OUT_TEXT = "d31e1d9d-2f33-64be-0642-655de5e9d001";

//Color for the window when the texture is set, default is white but can be changed to anything
vector TEXT_COLOR = <1.0, 1.0, 1.0>;

//Holds the original color of the window sides
vector baseInColor;
vector baseOutColor;

//Holds the original texture
string baseInText;
string baseOutText;

default
{
state_entry()
{
llListen(LISTEN_CHAN, "", NULL_KEY, "" );

//Save the base colors & textures
baseInColor = llGetColor(IN_SIDE);
baseOutColor = llGetColor(OUT_SIDE);
baseInText = llGetTexture(IN_SIDE);
baseOutText = llGetTexture(OUT_SIDE);

}//End state_entry

listen(integer channel, string name, key id, string message)
{
list listValues;
float tintValue;
integer sideToTint;

//Need to split out the side and tint values
listValues = llParseString2List(message,["@"],[""]);

//get the tintValue
tintValue = llList2Float(listValues,0)/100;

//now the side value
sideToTint = llList2Integer(listValues,1);

//Set the Alpha
llSetAlpha(tintValue, sideToTint);

//Now if this is 100% we need to change the color to white and set the texture
if (tintValue == 1)
{
if (sideToTint != OUT_SIDE)
{
llSetColor(TEXT_COLOR, IN_SIDE);
llSetTexture(IN_TEXT, IN_SIDE);
}
if (sideToTint != IN_SIDE)
{
llSetColor(TEXT_COLOR, OUT_SIDE);
llSetTexture(OUT_TEXT, OUT_SIDE);
}
}
//Otherwise we need to reset to the original color and texture
else
{

if (sideToTint != OUT_SIDE)
{
llSetColor(baseInColor, IN_SIDE);
llSetTexture(baseInText, IN_SIDE);
}

if (sideToTint != IN_SIDE)
{
llSetColor(baseOutColor, OUT_SIDE);
llSetTexture(baseOutText, OUT_SIDE);
}
}

}//End Listen
}//End Default
//
[/PHP]
_____________________