Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Menu Driven Window Tint Script

Abba Thiebaud
PerPetUal NoOb
Join date: 20 Aug 2006
Posts: 563
01-14-2007 15:20
Window tinting script using menu based options for a two story building, but can be modified however you'd like for whichever building style you have. This script controls several windows with one controller, varying the tinting from window to window as you choose the transparency level.

Critiques are appreciated and welcomed!

OK, main script (which goes into the controller prim)
CODE
// 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.
//
// (C) 2007 Abba Thiebaud>SecondLifer
// Please remember, I do not offer support for this script; your use of
// this script is your acknowledgement and agreement to the above
// terms.
//
// DO NOT REMOVE THE ABOVE HEADER FOR ANY REASON WHATSOEVER.

// Window Controller Script (put into controller prim)
list TINT_OPTIONS = ["40%", "20%", "None", "100%", "80%", "60%"];
list WALL_OPTIONS = ["Lower Front", "Lower Back", "Lower Sides", "Upper Front", "Upper Back", "Upper Sides", "Ceiling", "All"];
integer UPPER_FRONT = -28394;
integer LOWER_FRONT = -28395;
integer UPPER_BACK = -28396;
integer LOWER_BACK = -28397;
integer UPPER_SIDE = -28398;
integer LOWER_SIDE = -28399;
integer CEILING = -28400;
integer CHANNEL = -28393;
integer wallChannel;
integer allWalls;

PaintAllWalls(string tintLevel)
{
integer i;
integer j;

j = -28394;

for (i = 0; i < 7; i++)
{
llSay(j, tintLevel);
j--;
} // end for
} // end PaintAllWalls

default {
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
} // end state_entry()

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "Which wall would you like to tint?", WALL_OPTIONS, CHANNEL); // present dialog on click
allWalls = 0;
} // end touch_start()

listen(integer channel, string name, key id, string message)
{
if (llListFindList(TINT_OPTIONS + WALL_OPTIONS, [message]) != -1) // verify dialog choice
{
if (message == "Upper Front")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = UPPER_FRONT;
}
else if (message == "Upper Back")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = UPPER_BACK;
}
else if (message == "Upper Sides")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = UPPER_SIDE;
}
else if (message == "Lower Front")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = LOWER_FRONT;
}
else if (message == "Lower Back")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = LOWER_BACK;
}
else if (message == "Lower Sides")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = LOWER_SIDE;
}
else if (message == "Ceiling")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
wallChannel = CEILING;
}
else if(message == "All")
{
llDialog(id, "How much tint would you like?", TINT_OPTIONS, CHANNEL);
allWalls = 1;
}

if (message == "100%")
{
if(allWalls == 1)
{
PaintAllWalls("100");
}
else
{
llSay(wallChannel, "100");
}
}
else if (message == "80%")
{
if(allWalls == 1)
{
PaintAllWalls("80");
}
else
{
llSay(wallChannel, "80");
}
}
else if (message == "60%")
{
if(allWalls == 1)
{
PaintAllWalls("60");
}
else
{
llSay(wallChannel, "60");
}
}
else if (message == "40%")
{
if(allWalls == 1)
{
PaintAllWalls("40");
}
else
{
llSay(wallChannel, "40");
}
}
else if (message == "20%")
{
if(allWalls == 1)
{
PaintAllWalls("20");
}
else
{
llSay(wallChannel, "20");
}
}
else if (message == "None")
{
if(allWalls == 1)
{
PaintAllWalls("0");
}
else
{
llSay(wallChannel, "0");
}
}
} // end if (valid message)
} // end listen
} // end default


And the window script (which goes into the actual windows)
CODE
// 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.
//
// (C) 2007 Abba Thiebaud>SecondLifer
// Please remember, I do not offer support for this script; your use of
// this script is your acknowledgement and agreement to the above
// terms.
//
// DO NOT REMOVE THE ABOVE HEADER FOR ANY REASON WHATSOEVER.
//
//
//
//Here the target (aka Windows), put this script into them.
//integer chan = -28394; // uncomment for UPPER_FRONT
//integer chan = -28395; // uncomment for LOWER_FRONT
//integer chan = -28396; // uncomment for UPPER_BACK
//integer chan = -28397; // uncomment for LOWER_BACK
//integer chan = -28398; // uncomment for UPPER_SIDE
//integer chan = -28399; // uncomment for LOWER_SIDE
//integer chan = -28400; // uncomment for CEILING

//START SCRIPT
default
{
state_entry()
{
llListen(chan, "", NULL_KEY, "" );
}

listen( integer channel, string name, key id, string message )
{
if ( message == "100" )
{
llSetAlpha(1.0, ALL_SIDES);
}
else if ( message == "80" )
{
llSetAlpha(0.8, ALL_SIDES);
}
else if ( message == "60" )
{
llSetAlpha(0.6, ALL_SIDES);
}
else if ( message == "40" )
{
llSetAlpha(0.4, ALL_SIDES);
}
else if ( message == "20" )
{
llSetAlpha(0.2, ALL_SIDES);
}
else if ( message == "0" )
{
llSetAlpha(0.0, ALL_SIDES);
}
}
}
//////END SCRIPT
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
01-15-2007 23:12
/15/73/160510/1.html
_____________________
i've got nothing. ;)
Shippley Dittmann
Registered User
Join date: 30 Aug 2006
Posts: 13
error
02-18-2007 17:31
error: Name not definded within scope.

(33,29)

I think its the State Entry line
llListen(chan
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
02-18-2007 19:05
Shippley, you need to un-comment one of the declarations of chan as it says to do.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-19-2007 01:29
I'm pretty sure we covered this code previous in another thread but by the looks of it very few of the suggestions have been picked up.

You have an open listen which is poor practise. It should only be active when someone is actually using the item. Add a large timeout if you need to but it should still be constrained.

Your not using constants consistantly, you define UPPER_FRONT as -28394 and yet then make j = -28394 rather than using UPPER_FRONT. If you define a constant use it!

You repeat the check for allWalls for every alpha, move that code into the subroutine.

you are converting "20%" to "20" just to say it, not a very efficient way to do things, especially since the other end performs a cast to integer on the code which will give the exact same results with "20%" as "20" or "0" as "none".
Garry Tanner
Registered User
Join date: 21 Jul 2006
Posts: 1
08-23-2007 18:55
I am very new to this scripting.

I have heavily modified the script for a color changer in shoes. But I am still coming up with the same issue as I had some time ago with another script. The script listens to everyone and all ojects. But I want it to listen to my objects only. Lets examine the related code:

As it is now:
llListen(CHANNEL, "", NULL_KEY, "";); // listen for dialog answers (from multiple users)
Listens to everything.

Now I changed the "NULL_KEY" to "llGetOwner()" , and got as follows:
llListen(CHANNEL, "", llGetOwner(), "";); // listen for dialog answers (from multiple users)
Only listens to my text chat.

Which works fine if I type in chat, but I want it to listen to objects owned by myself only, as well as my text commands. Listening to my text chat is not neccesary.

But I have a controller I want my color changers to listen to.

Any hints please?
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
08-24-2007 07:12
Best thing to do is change the listen back to NULL_KEY, put the channel on some ridiculous negative channel.

In your listen state, I would surround your checks against the message with:

if ((llGetOwnerKey(id) == Owner) || (id == Owner))
{
//Do your current listen stuff here
}
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
08-24-2007 07:31
I really wonder why people bother with locking doors and tinting windows. With the camera movement and other tricks, they are useless. Anybody can still see inside your house, and a lot of ppl will even still be able to get in your house unless you use access control thru land options or a security orb.

Locking doors and tinting windows offer no privacy but do cause lag due to their listeners.
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
08-24-2007 08:56
From: Lyn Mimistrobell
I really wonder why people bother with locking doors and tinting windows. With the camera movement and other tricks, they are useless. Anybody can still see inside your house, and a lot of ppl will even still be able to get in your house unless you use access control thru land options or a security orb.

Locking doors and tinting windows offer no privacy but do cause lag due to their listeners.

As in the real world, security isn't a matter of absolutes. It's a matter of doing something simple that will address a large part of the problem.

In this case, the issue probably isn't preventing determined people from looking inside. It's preventing wanderers from seeing what's going on inside accidentally, and being attracted to it. Lots of people might stop and gawk (or worse) if they saw something interesting, but they're not going to spend time trying to break into every single place with closed windows.

Also, if you're renting and you can't get an orb with land owner permissions, it can be bypassed, too.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
08-24-2007 10:01
From: Lyn Mimistrobell
I really wonder why people bother with locking doors and tinting windows. With the camera movement and other tricks, they are useless. Anybody can still see inside your house, and a lot of ppl will even still be able to get in your house unless you use access control thru land options or a security orb.

Locking doors and tinting windows offer no privacy but do cause lag due to their listeners.


Also, a good portion of buildings have primarly windows for walls and this just gives good customization options for people who might buy them. Some may prefer dark tinted or completely see-through.

I would think it better to have it separated into inside and outside on buildings such as these...to change the transparency only on one side or the other, but this normally does all that people really care about.
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
08-24-2007 12:37
From: Lyn Mimistrobell
I really wonder why people bother with locking doors and tinting windows. With the camera movement and other tricks, they are useless. Anybody can still see inside your house, and a lot of ppl will even still be able to get in your house unless you use access control thru land options or a security orb.

Locking doors and tinting windows offer no privacy but do cause lag due to their listeners.


Maybe so but I know I have had many newbies tried to gain access numerous times through a locked door then decided to go elsewhere after their many failed attempts.
So it does help some.
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
08-24-2007 14:42
From: Lyn Mimistrobell
I really wonder why people bother with locking doors and tinting windows. With the camera movement and other tricks, they are useless. Anybody can still see inside your house, and a lot of ppl will even still be able to get in your house unless you use access control thru land options or a security orb.

Locking doors and tinting windows offer no privacy but do cause lag due to their listeners.


Its the illusion of privacy. Everybody knows how easy it is to move your camera into a house. But would you rather have a private moment with your partner with all eyes on you or behind a closed door.
Also those security orbs cause lag with the constant scans. Only lagless option is to use landtools and clutter up the property with the do not enter strips all around your parcel. Personally, I don't mind the tinting windows and locking doors. Its a nice feature to add value to a build.