Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Window Tint Script Problem

Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
02-19-2008 19:41
Hello folks … I’m having troubles making my window tint script to work correctly. I have a house with 19 windows, spread out on three floors, I placed the first script in all my windows and the second script in the control unit. When I click on the control unit and select a tint percentage, only half the windows change to that tint percentage, (only the windows on the side of the house that controller is located at). I’m I doing something wrong? Any help would be greatly appreciated.

----------------------------------------------------------------------------------------
//place this script in all the windows
default
{
state_entry()
{
llListen( -37641, "", 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);
}
}
}
--------------------------------------------------------------------------------------------

//Main Script (Send Unit) :
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
menu_channel = -37641 ; // You can change the Channel as needed...to add more systems into one house, but dont forget to change the channels in the Window (Target) Script too)
menu_handler = llListen(menu_channel,"","","";);
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(5.0);
}
default
{
touch_start(integer t)
{
menu(llDetectedKey(0),"Window Tinting System",["100","80","60","40","20","0"]);
}
timer()
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel)
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
if(message == "100";)
{
llSay(menu_channel,"100";);
}
else if(message == "80";)
{
llSay(menu_channel,"80";);
}
else if(message == "60";)
{
llSay(menu_channel,"60";);
}
else if(message == "40";)
{
llSay(menu_channel,"40";);
}
else if(message == "20";)
{
llSay(menu_channel,"20";);
}
else if(message == "0";)
{
llSay(menu_channel,"0";);
}
}
}
}
Echo Dragonfly
Surely You Jest
Join date: 22 Aug 2004
Posts: 325
02-19-2008 19:47
Taking a stab at it, I think your controller is doing that due to the chat limitation (20 meters).
If your other windows are farther than 20 meters from the controller, they can't "Hear" the opacity change message.

You might try replacing the llSay in the outgoing messages with llRegionSay.
_____________________
Creativity represents a miraculous coming together of the uninhibited energy of the child with its apparent opposite and enemy, the sense of order imposed on the disciplined adult intelligence.
Norman Podhoretz
......................
If quizzes are quizzical, what are tests? :eek:
............................
Do illiterate people get the full effect of Alphabet Soup? :rolleyes:
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-19-2008 20:05
Also, instead of having a ton of if statements, you could do..

list buttons = ["0", "20", "40", "60", "80", "100"];

...

{
integer index = llListFindList(buttons, [msg]);
if (index > -1) {
llSetAlpha(llList2Float(buttons, index) / 100.0, ALL_SIDES);
}
}

And similarly for the chat output.
_____________________
Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
02-19-2008 20:11
thanks to the both of you for your replys ....

btw Echo, your "stab at it" was dead on ... just tried it out and it works like a champ.

thanks again to Echo & Tyken for your quick replys.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
02-19-2008 21:15
just to use as thought food...

default
{
state_entry()
{
llListen( 55, "", NULL_KEY, "" );
}

listen( integer channel, string name, key id, string message )
{
llSetAlpha(((float)message / 100), ALL_SIDES);
}
}
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-19-2008 22:27
From: Osgeld Barmy
just to use as thought food...

default
{
state_entry()
{
llListen( 55, "", NULL_KEY, "" );
}

listen( integer channel, string name, key id, string message )
{
llSetAlpha(((float)message / 100), ALL_SIDES);
}
}

This is nice when the message is valid; that's why I'd check it against a list.
_____________________
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
02-19-2008 22:48
oops totally missed your post

sorry
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-19-2008 22:50
From: Osgeld Barmy
oops totally missed your post

sorry

No need to be sorry for anything. :o
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-19-2008 23:01
shortcut the whole thing by saying the number back as your percentage, using negative channels for all of it, you can error check it by testing that the heard command came from an av (because the only way for an av to speak on a negative channel is through a dialog).

CODE

listen( integer channel, string name, key id, string message ){
if (llGetAgentSize( id )){
llRegionSay( -55, (string)((float)message / 100.0) );
}
}

then in your sub scripts just allpy the alpha directly

and null key in the listen call can be replaced with "", same effect, ~54bytes less memory used.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-19-2008 23:08
From: Void Singer
you can error check it by testing that the heard command came from an av (because the only way for an av to speak on a negative channel is through a dialog).


This is ingenious. Bravo.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-19-2008 23:52
it's not perfect... if another dialog were to use that channel at the same time it could get very VERY messy, but really we're talking about window tinting, so what are the odds of true disaster? I suppose you could further bulletproof it by listening only to the triggering av, (or controlling prim name in the subs case)... in fact that'd work better than testing that it's an agent speaking since it'd ignore anyone but the person that the dialog was triggered for.

I do see one problem with the way the listen is removed... if a second dialog is started before the first is removed, the only way for the first to be removed would be if it was responded to... this could leave accumulating open listens if the dialog gets ignored in such cases as a doubleclick....

better than running listen remove is changing states after a longer timeout (5 sec is pretty fast on a laggy sim), then switching back... it'd be possible to accumulate a few listens at once, but they'd be guaranteed to be cleared
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -