I tried the approach of turning lights on and off on the basis of the sun's Z position but had poor results, so I created a prim and had it report the sun position every 10 seconds:
default
{
state_entry()
{
llSetTimerEvent(10.0);
}
timer()
{
vector sun = llGetSunDirection();
llSetText("Sun X = " + (string)sun.x + "\nSun Y = " + (string)sun.y + "\nSun Z = " + (string)sun.z, <1.0,1.0,0.0>, 1.0);
}
}
What I found is that one "evening" the Sun was still casting shadows when Z was -0.47; the next "morning" the sun resumed casting shadows when it was at Z = -0.87, so the method of using Z < 0 for night seems like it won't work reliably?
Some math makes more sense of this, maybe. Z = -.87 and Z = -.47 are when the sun is 60 and 28 degrees below the horizon, respectively. This means the sun was "up" for a total of 60+28+180, or 268 degrees. Probably if I had measured more carefully that would be 270 degrees, or exactly 3/4 of a circle. This makes sense because the sun is "up" for three hours out of four. For some reason there's a 15 degree offset included in this.