Code summary:
This simple script merely conducts actions when either sunrise or sunset occur.
// Day-night check action script
// Performs different actions when it becomes light or dark, checking
// every minute.
// Ordinal Malaprop
// 2006-06-20
integer daytime()
{
vector sun = llGetSunDirection();
return (sun.z >= 0.0);
}
default
{
state_entry()
{
llSetTimerEvent(60.0);
if (!daytime()) state night;
// insert things to be done in the day e.g.
llOwnerSay("I now think it is daytime");
}
timer()
{
if (!daytime()) state night;
}
on_rez(integer p)
{
llResetScript();
}
}
state night
{
state_entry()
{
// insert things to be done in the night e.g.
llOwnerSay("I now think it is nighttime");
}
timer()
{
if (daytime()) state default;
}
on_rez(integer p)
{
llResetScript();
}
}