Page 1 of 1

Adding Full Bright to Light Script

Posted: Fri May 24, 2019 2:25 pm
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]);
        }
    }    
}

Re: Adding Full Bright to Light Script

Posted: Fri May 24, 2019 6:03 pm
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]);
        }
    }    
}

Re: Adding Full Bright to Light Script

Posted: Sat May 25, 2019 5:14 am
by Natalie Oe
Thank you so very much Graham. That was exactly what I was looking for.

Re: Adding Full Bright to Light Script

Posted: Mon May 27, 2019 11:56 am
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.

Re: Adding Full Bright to Light Script

Posted: Sat Jun 01, 2019 11:28 pm
by Natalie Oe
Thank you Brayla!!