Adding Full Bright to Light Script

Creating scripts
Post Reply
User avatar
Natalie Oe
Posts: 48
Joined: Mon May 07, 2018 10:15 am
Has thanked: 21 times
Been thanked: 21 times
Contact:

Adding Full Bright to Light Script

Post by Natalie Oe »

Hi All,

Wondering if anyone can help. I have a light script (posted below) its controlled via a remote switch and all works great. However, I would like the light bulb to also switch to full bright when on and switch off when the light is off. I tried to do it myself but just got a massive headache. I'm happy to compensate for the minor adjustment if necessary.

Here is the bulb script:

Code: Select all

//Simple remote light by Adelle Fitzgerald. Use as you like but please keep this header.

integer channel = 20; //Set this to the same channel as your switch. If you want to operate more than one light individually then set to a diffetent channel (not 0) and set the same channel in the switch script
float intensity = 1.0; //Set this to the brightness of the light (0.0 - 1.0)
float radius = 5; //Set this to the light radius in meters (0.0 - 20.0)
float falloff = 2.0; //Set this to the falloff of the light (0.0 - 2.0)
vector colour = <1,1,1>; //colour of the light <R,G,B> (0.0 - 1.0)

default
{
    state_entry()
    {
        llListen(channel,"","","");
    }
    
    listen (integer channel, string name, key id, string message)
    {
        if (message == "on")
        {
            llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,colour,intensity,radius,falloff]);
        }
        if (message == "off")
        {
            llSetPrimitiveParams([PRIM_POINT_LIGHT,FALSE,colour,intensity,radius,falloff]);
        }
    }    
}
These users thanked the author Natalie Oe for the post (total 2):
Ilan TochnerZed deTremont
Australian Digital Creator | She/Her | Coffee Addict | Book Lover | Aspiring Scrapbooker.

Kitely Marketplace
True Blue Digital Designs
Instagram
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Adding Full Bright to Light Script

Post by Graham Mills »

Like this?

Code: Select all

//Simple remote light by Adelle Fitzgerald. Use as you like but please keep this header.

integer channel = 20; //Set this to the same channel as your switch. If you want to operate more than one light individually then set to a diffetent channel (not 0) and set the same channel in the switch script
float intensity = 1.0; //Set this to the brightness of the light (0.0 - 1.0)
float radius = 5; //Set this to the light radius in meters (0.0 - 20.0)
float falloff = 2.0; //Set this to the falloff of the light (0.0 - 2.0)
vector colour = <1,1,1>; //colour of the light <R,G,B> (0.0 - 1.0)

default
{
    state_entry()
    {
        llListen(channel,"","","");
    }
    
    listen (integer channel, string name, key id, string message)
    {
        if (message == "on")
        {
            llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,colour,intensity,radius,falloff, PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
            
        }
        if (message == "off")
        {
            llSetPrimitiveParams([PRIM_POINT_LIGHT,FALSE,colour,intensity,radius,falloff, PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
        }
    }    
}
These users thanked the author Graham Mills for the post (total 2):
Natalie OeZed deTremont
User avatar
Natalie Oe
Posts: 48
Joined: Mon May 07, 2018 10:15 am
Has thanked: 21 times
Been thanked: 21 times
Contact:

Re: Adding Full Bright to Light Script

Post by Natalie Oe »

Thank you so very much Graham. That was exactly what I was looking for.
These users thanked the author Natalie Oe for the post:
Graham Mills
Australian Digital Creator | She/Her | Coffee Addict | Book Lover | Aspiring Scrapbooker.

Kitely Marketplace
True Blue Digital Designs
Instagram
User avatar
Brayla Sana
Posts: 78
Joined: Wed Mar 27, 2013 7:09 pm
Has thanked: 19 times
Been thanked: 144 times

Re: Adding Full Bright to Light Script

Post by Brayla Sana »

I want to make this a bit more efficient for you, because it looks like you want to use it in your builds.
See this thread viewtopic.php?t=1149 on why I replaced llSetPrimitiveParams([]); with llSetLinkPrimitiveParamsFast(LINK_THIS,[]);

Code: Select all

// Simple remote light by Adelle Fitzgerald. Use as you like but please keep this header.
// Brayla changed the LSL function to a better one.

integer channel = 20; //Set this to the same channel as your switch. If you want to operate more than one light individually then set to a different channel (not 0) and set the same channel in the switch script
float intensity = 1.0; //Set this to the brightness of the light (0.0 - 1.0)
float radius = 5; //Set this to the light radius in meters (0.0 - 20.0)
float falloff = 2.0; //Set this to the falloff of the light (0.0 - 2.0)
vector colour = <1,1,1>; //colour of the light <R,G,B> (0.0 - 1.0)

default
{
    state_entry()
    {
        llListen(channel,"","","");
    }
    
    listen (integer channel, string name, key id, string message)
    {
        if (message == "on")
        {
            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POINT_LIGHT,TRUE,colour,intensity,radius,falloff]);
        }
        if (message == "off")
        {
            llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POINT_LIGHT,FALSE,colour,intensity,radius,falloff]);
        }
    }    
}
You will also want to change the channel to a negative number; only scripts can use negative chat channels and this reduces potential conflicts with chat channels used by the viewer.
These users thanked the author Brayla Sana for the post (total 2):
Graham MillsNatalie Oe
Dadiella's for Fashion and Brayla Sana Gallery for Building!
User avatar
Natalie Oe
Posts: 48
Joined: Mon May 07, 2018 10:15 am
Has thanked: 21 times
Been thanked: 21 times
Contact:

Re: Adding Full Bright to Light Script

Post by Natalie Oe »

Thank you Brayla!!
Australian Digital Creator | She/Her | Coffee Addict | Book Lover | Aspiring Scrapbooker.

Kitely Marketplace
True Blue Digital Designs
Instagram
Post Reply