Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Lightswitch Script help

Jonathan Mulberry
Registered User
Join date: 15 Nov 2006
Posts: 106
01-16-2007 06:11
Was wondering if any of you could help. I've been hunting around trying to find what i would have presumed would be a fairly straightforward script to find, but have so far come up with nothing after searching SL and the various LSL scripting websites.

I have built myself a nice floor standing uplighter lamp. What I am looking for is a script that i can drop in to the stand so that when I touch the stand it turns the light on, touch it again it turns the light off.

I presume it would need to be 2 scripts, 1 a controller placed in the stand itself, and the other the script that turns the light on or off placed in the bulb.

Ideally I'd like it to be copy/trans/mod so that I can look at the script and learn from it and then maybe tweak it to do different things, but to start with any script that worked would do.

Cheers in advance
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 06:32
From: Jonathan Mulberry
Was wondering if any of you could help. I've been hunting around trying to find what i would have presumed would be a fairly straightforward script to find, but have so far come up with nothing after searching SL and the various LSL scripting websites.

I have built myself a nice floor standing uplighter lamp. What I am looking for is a script that i can drop in to the stand so that when I touch the stand it turns the light on, touch it again it turns the light off.

I presume it would need to be 2 scripts, 1 a controller placed in the stand itself, and the other the script that turns the light on or off placed in the bulb.

Ideally I'd like it to be copy/trans/mod so that I can look at the script and learn from it and then maybe tweak it to do different things, but to start with any script that worked would do.

Cheers in advance


Please Note, this forum is really for people trying to write their own scripts,
it is not intended as a free script writing service.


If you link such that the light itself is the root prim you will only need the following script

CODE

integer On = FALSE;
vector Colour = < 1,1,1>; // Your light colour (1,1,1 = white)

SetLight()
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, On, Colour, 1.0, 1.0, 0.5]);
}

default
{
state_entry()
{
On = FALSE;
SetLight();
}

touch_start(integer num_detected)
{
On = ! On;
SetLight();
}
}
Jonathan Mulberry
Registered User
Join date: 15 Nov 2006
Posts: 106
01-16-2007 06:58
From: Newgate Ludd
Please Note, this forum is really for people trying to write their own scripts,
it is not intended as a free script writing service.


I am aware of that Newgate, I just thought someone here may know of a script already available what with this being an area frequented by scripters.

Thanks for the script you have written. Next I need to figure out how to make it switch on 2 'bulbs' in the same lamp... i guess for this I may have to go the way of controller script/light script.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 07:18
From: Jonathan Mulberry
I am aware of that Newgate, I just thought someone here may know of a script already available what with this being an area frequented by scripters.


Sorry if my reply seemed terse but a search of this forum would have given you several examples. Ergo you didnt search first and I assume the worst!

From: Jonathan Mulberry
Thanks for the script you have written. Next I need to figure out how to make it switch on 2 'bulbs' in the same lamp... i guess for this I may have to go the way of controller script/light script.


This topic has been covered previously here
Jonathan Mulberry
Registered User
Join date: 15 Nov 2006
Posts: 106
01-16-2007 09:05
Thanks for your help Newgate, I've managed to alter the script you supplied on that link to turn a light source on and off instead of making it transparent.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 13:34
From: Jonathan Mulberry
Thanks for your help Newgate, I've managed to alter the script you supplied on that link to turn a light source on and off instead of making it transparent.


Good for you.
The orginal script was for a light where I just made a light cone prim visible or invisible. Back before we had working light sources....