Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help with daylight auto detect light/shiny

Lefty Belvedere
Lefty Belvedere
Join date: 11 Oct 2004
Posts: 276
11-29-2005 14:53
I'm using the following script to turn lights on and off with daylight. But since the updates, we can now have something give off light while still being reflective.

I need somebody to add a line in here to set shiny to none at night and med during the day. Your quick edit would be very much apreciated as i have little experience with scripts outside of value changing.

Thank You in advance,
~Lefty


From: someone
// My Light Control (no dataserver)
// Chromal Brodsky
// v0.0.4 - 2004-03-30
//
// Controls a light based upon the virtual time of day.
//
// v0.0.1 - 0.0.3 - initial revs
// v0.0.4 - uses the new llSetPrimitiveParams() call to disable client light rendering when off!

float fTime = 0;
float fDayThresh = 0.66;
float fNightThresh = 3.46;
integer iTimerSecs = 300;
string sOutPre;

init()
{
sOutPre = llGetScriptName() + ": ";

refresh();
llSetTimerEvent(iTimerSecs);

llWhisper(0, sOutPre + (string)fTime + ": startup...";);
llWhisper(0, "Timer interval is: " + (string)iTimerSecs + " seconds.";);
}

refresh()
{
fTime = llGetTimeOfDay() / 3600.0;
}

set_light(integer iOn)
{
if (iOn == TRUE)
{
llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_LIGHT] );
}
else
{
llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_GLASS] );
}
}

integer IsDay(float fTimeOfDay)
{
integer iDay;

if ( fTimeOfDay > fDayThresh && fTimeOfDay < fNightThresh )
{
iDay = TRUE;
}
else
{
iDay = FALSE;
}

return iDay;
}

default
{
state_entry()
{
init();
if ( IsDay(fTime) )
{
state Day;
}
else
{
state Night;
}
}
}

state Day
{
state_entry()
{
refresh();
set_light( FALSE );
}

timer()
{
refresh();
if ( !IsDay(fTime) )
{
state Night;
}
}
}

state Night
{
state_entry()
{
refresh();
set_light( TRUE );
}

timer()
{
refresh();

if ( IsDay(fTime) )
{
state Day;
}
}
}
Lefty Belvedere
Lefty Belvedere
Join date: 11 Oct 2004
Posts: 276
11-29-2005 14:54
// My Light Control (no dataserver)
// Chromal Brodsky
// v0.0.4 - 2004-03-30
//
// Controls a light based upon the virtual time of day.
//
// v0.0.1 - 0.0.3 - initial revs
// v0.0.4 - uses the new llSetPrimitiveParams() call to disable client light rendering when off!

float fTime = 0;
float fDayThresh = 0.66;
float fNightThresh = 3.46;
integer iTimerSecs = 300;
string sOutPre;

init()
{
sOutPre = llGetScriptName() + ": ";

refresh();
llSetTimerEvent(iTimerSecs);

llWhisper(0, sOutPre + (string)fTime + ": startup...";);
llWhisper(0, "Timer interval is: " + (string)iTimerSecs + " seconds.";);
}

refresh()
{
fTime = llGetTimeOfDay() / 3600.0;
}

set_light(integer iOn)
{
if (iOn == TRUE)
{
llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_LIGHT] );
}
else
{
llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_GLASS] );
}
}

integer IsDay(float fTimeOfDay)
{
integer iDay;

if ( fTimeOfDay > fDayThresh && fTimeOfDay < fNightThresh )
{
iDay = TRUE;
}
else
{
iDay = FALSE;
}

return iDay;
}

default
{
state_entry()
{
init();
if ( IsDay(fTime) )
{
state Day;
}
else
{
state Night;
}
}
}

state Day
{
state_entry()
{
refresh();
set_light( FALSE );
}

timer()
{
refresh();
if ( !IsDay(fTime) )
{
state Night;
}
}
}

state Night
{
state_entry()
{
refresh();
set_light( TRUE );
}

timer()
{
refresh();

if ( IsDay(fTime) )
{
state Day;
}
}
}
Davan Camus
Registered User
Join date: 13 Sep 2005
Posts: 67
11-29-2005 17:15
Hooray! something I can answer.

You can extend the llSetPrimitiveParams:

llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_LIGHT] );

becomes

llSetPrimitiveParams( [PRIM_MATERIAL, PRIM_MATERIAL_LIGHT,
PRIM_BUMP_SHINY,ALL_SIDES,PRIM_SHINY_NONE,PRIM_BUMP_NONE] );


and for the day-time one, use PRIM_SHINY_MEDIUM.

(I'm typing this without trying it, so pardon any typos. Be sure to see the LSL Wiki entry:
http://secondlife.com/badgeo/wakka.php?wakka=llSetPrimitiveParams )
_____________________
Visit Cubes at Alice 100,18.
--------------------------------------------------
Davan Camus, born: 2005 September 8
Out-world location: Santa Cruz, CA
UI Proposal: http://davancamus.hexaflexagon.com/blog/?p=39
Lefty Belvedere
Lefty Belvedere
Join date: 11 Oct 2004
Posts: 276
11-30-2005 19:23
it works and I thank you for stepping up and helping me out. Many thanx


~Lefty