Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Lights on and off Help

Pablicious Pessoa
Registered User
Join date: 27 Jun 2007
Posts: 64
09-19-2007 13:43
Hey all,

I'm confused....I've been messing around with a few scripts that'll check position of the sun and turn on or off lights. However, the scripts never work, tried a few different one but they all seem to have the same syntax.

Here is the current script I want to use:

integer e;

default
{
state_entry()
{
llSetTimerEvent(300.0);
}

timer()
{
vector sun_dur = llGetSunDirection();
integer a=(sun_dur.z<0)*(PRIM_MATERIAL_STONE - PRIM_MATERIAL_LIGHT) + PRIM_MATERIAL_LIGHT;
if (e!=a)
llSetPrimitiveParams([PRIM_MATERIAL,e=a]);
}
}

What I don't understand is what do I do with PRIM_MATERIAL_STONE - PRIM_MATERIAL_LIGHT? DO I replace this with the name of the texture to be used for stone and light? Or do I just put textures of stone and light in the inventory of the prim to be used for light?

Thanks for your help!
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
09-19-2007 13:50
The texture doesn't come into play, the script is setting the properties of the object to either emit light or not. If you turn on 'local lights' from preferences, you should see the object glow at night. Those values PRIME_MATERIAL_X are values that are known by the language and represent certain object properties, so you should just be able to drop the script in an object and not touch it.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
09-19-2007 13:59
try this:


integer night=0; // 0 = daytime, 1 = nighttime

default
{
state_entry()
{
llSetTimerEvent(300); // Check every 5 minutes
}
timer()
{
vector sun = llGetSunDirection();
if (sun.z <= 0) night = 1; // Sun is below the horizon
else if (sun.z > 0) night = 0; // Sun is above the horizon
}
touch_start(integer total_number)
{
if (night == 1) llSay(0, "It's nighttime.";);
else if (night == 0) llSay(0, "It's daytime.";);
}
}
Pablicious Pessoa
Registered User
Join date: 27 Jun 2007
Posts: 64
09-19-2007 14:31
LOL

I must be dumb.

I've used the script provided by Johan (Thanks!!!!) but I get the same results no matter what. The light never seems to turn on or off. Do I enable the light option for the prim? Or not? Does the script turn it on? If I enable the light, does it disable the script? Does this work when I force the sun to day or night or do I have to wait for SL's natural sun cycle to see if this really works or not.

All I know is that right now it's daytime, I've got a square prim floating in the air. The light function is turned on but the script never turns it off. I click on it, it says, "It's daytime." but nothing else happens.

I know this is a simple script but what the heck am I doing wrong?
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
09-19-2007 15:52
Here is a script that I know works. The light goes on and off with the light in the sim. I use it in the lights that I make.
Enjoy

default
{
state_entry()
{
llSetTimerEvent(4);
}
timer()
{
vector sun = llGetSunDirection();
if(sun.z > 0)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 1, 1>, 1.0, 10.0, 0.75]);
llSetColor (<0.5,0.5,0.5>, ALL_SIDES);
}
else
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 1, 1>, 1.0, 20.0, 0.00]);
llSetColor (<1,1,1>, ALL_SIDES);
}
}
}
Pablicious Pessoa
Registered User
Join date: 27 Jun 2007
Posts: 64
09-19-2007 16:30
Robin,

Thank you very very very VERY much. I must have tried 10 different scripts but yours actually works.

THANK YOU!!!!!!!!!!!

Pablo