Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

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
Discussion Thread
01-15-2007 23:12
/54/a7/160769/1.html
_____________________
i've got nothing. ;)
Marcello Lutetia
Registered User
Join date: 15 Nov 2006
Posts: 1
Thank You.
01-25-2007 10:45
Nice simple menuing script that I can use to understand menuing. Just what I needed as a newbie to Scripting. Thank You.
Shippley Dittmann
Registered User
Join date: 30 Aug 2006
Posts: 13
Error: Named not defined within scope
02-19-2007 08:19
I am getting an error when trying to save the script that is in the window. Its telling me:

(33,29) : ERROR : Name not defined within scope.



Any idea what I'm doin wrong? What do I need to change?

Thanks,
Shippley
Wolfgang Zhichao
Registered User
Join date: 6 Jan 2007
Posts: 10
Compile Error
02-20-2007 17:37
when i compile the script for the window, i get an error:

llListen(chan, "", NULL_KEY, "" );

as an extream noob to scripting, i have no clue how to fix it. i'm going to try to fix it on my own... thats how i like to learn...:)
Marc Sylbert
Registered User
Join date: 27 Mar 2007
Posts: 0
Menu Driven Window Tint Script
05-02-2007 05:45
Thank you, Abba, works really fine :-)
sublicious Ramos
coke and a candy bar
Join date: 23 Sep 2003
Posts: 10
script help please
10-06-2007 07:33
I am trying the menu windows script. 1st part of script was fine, but 2nd part of script gave me this error......

(33, 13) : ERROR : Name not defined within sc

i understand the line 33, 13 where the problem is, but dont understand what sc is and how to fix it :)
sublicious Ramos
coke and a candy bar
Join date: 23 Sep 2003
Posts: 10
script not working
10-14-2007 17:04
Would anyone know why i receive the error... name not defined within sc...
after llListen(chan, "", NULL_KEY, "" ); the error is after chan
Anubis Bishop
Registered User
Join date: 13 Feb 2006
Posts: 5
Menu Driven Window Tint Script
11-18-2007 01:31
can a shout be put in the script so it can go to a farther distance then 20 meters?