Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Lighting Script

RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
07-07-2006 08:01
I Need A Script That Will Toggle Local Lighting On And Off Within A Prim......And How Hard Would It Be To Get A Menu Pop Up With Diffrent Color Choices For The Lighting If One Of You Could Point Me In The Direction Of One Already Posted Or Whip One Up For Me Itd Be Much Apreciated Ive Search For Light And It Seems To Bring Up Everything But What Im Actually Looking For......
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
07-07-2006 08:42
If you mean toggle a light on/off like a lightbulb, that is not that difficult . . . "local lighting" usually refers to a client setting in SL, which cannot be changed via script to the best of my knowledge.

If you are interested in a custom script to do what you want, cccontact me for details on one.

Baron H.
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
......
07-07-2006 08:57
Someone Online Pls Post Reply Makes It Easier That Way ;-) Or Post The Script If It Can Be Done To Toggle Local Lighting Or A Idea Of How To Give The Apearance Of Light On And Off The Simple Light Script jus Turns The Prim Black.... Definitly Not What Im Looking For
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
07-07-2006 09:22
I just posed the script you need to the scripting library. Should be up as soon as the moderator approves it.

The script features are:

* Touch On/Off
* Listens to owner and allows the color of the light to be changed
* Low lag - listens to owner on touch only and cancels the listen after 30 seconds
* Free :D

-2fast
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
Very Kewl
07-07-2006 09:32
From: 2fast4u Nabob
I just posed the script you need to the scripting library. Should be up as soon as the moderator approves it.

The script features are:

* Touch On/Off
* Listens to owner and allows the color of the light to be changed
* Low lag - listens to owner on touch only and cancels the listen after 30 seconds
* Free :D

-2fast

Kick A** Exactly What I Was Looking For Tyvm If It Gets Aproved And Posted Be Expecting A "tip" For Your Generosity
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
07-07-2006 12:23
Looks like it might take a while to show up in the scripting library....

Here is the code....

CODE

// Sample touch lighting LSL script with color change capability - 07/07/2006 - 2fast4u Nabob
//
// * Permission granted to modify and create derivative works.
// * If you sell this script, include attribution to 2fast4u Nabob, the author of
// this script in your product's documentation.
//
// Provided "as is"
//
// Features:
//
// *Touch On/Off
// *Listens to owner and allows the color of the light to be changed
// *Low lag - listens to owner on touch only and cancels the listen after 30 seconds
//
// Instructions:
//
// 1.Place this script into a prim that you want to light-up when touched
// 2. Thank 2fast4u Nabob for helping you :)
//

// channel_num is the channel that the light listens on. Type /5555 ... to talk to the light
integer channel_num=5555;
// colorWords lists the colors that the light supports - add here and in colorVectors
list colorWords=["white","red","green","blue"];
// colorVectors represent the color values that the light supports
list colorVectors=[<1.0,1.0,1.0>,<1.0,0.0,0.0>,<0.0,1.0,0.0>,<0.0,0.0,1.0>];

// Don't edit anything below this line

integer isOn=FALSE;
vector light_color;

integer listenHandle=0;

// This makes it easier to change the light's parameters in one place
setLightParameters()
{
llSetPrimitiveParams ([PRIM_POINT_LIGHT, isOn, light_color, 1.0, 10.0, 0.75]);
}

default
{
on_rez(integer start_param)
{
llResetScript(); //Reset in case owner changed
light_color=llList2Vector(colorVectors,0); //Set the initial color to white
}

touch_start(integer num_detected)
{
// If not already listening, start listening to the owner
if(listenHandle==0)
{
listenHandle=llListen(channel_num,"",llGetOwner(),"");
llSetTimerEvent(30.0);
}
// Toggle the light on/off
isOn = !isOn;
// Set the light's parameters
setLightParameters();
}

timer()
{
// If the script is listening, stop listening and stop the timer to reduce lag
if(listenHandle!=0)
{
llListenRemove(listenHandle);
llSetTimerEvent(0.0);
}
}

listen(integer channel, string name, key id, string message)
{
// The following IF statement is for the paranoid :) Not really necessary to check the
// id against the owner, but no harm in doing it anyway
if(channel != channel_num || id!=llGetOwner())
return;
// Look for what the user says in the list....
integer listLocation;
listLocation=llListFindList(colorWords,[message]);
// Did not find what the user said in the list? Stop here
if(listLocation == -1)
return;
// found what the user said in the list, set the corresponding vector
light_color=llList2Vector(colorVectors,listLocation);
// set the light's parameters - does not change On/Off setting
setLightParameters();
}
}



Place into the prim you want to light-up. Touch to turn on/off. When touched (light can be on or off), this listens to the following commands:

/5555 white
/5555 red
/5555 blue
/5555 green

The commands change the color of the light. The light stopps listening to the owner after 30 seconds. Anyone can turn the light on or off.

-2fast