one more silly thing
This little project still took me two afternoon, well itsnot a simple clock, its a solar clock, the SL sun do not move in the sky at a constant speed, 3 hours of day for 1 hour of night, so the sl day last for a total of 4 real hours, on top of not exactly orbiting SL, it effectively move faster during the night. What my clock do is give the hour according to the sun position, so when the sun is at the zenit, it mark noon, and when the moon is high it mark midnight. So it makes it more like a relative clock as the hours move twice as fast during the night, and of course if it is placed in a private sim with sun frozen, the clock will stay frozen at the sun hour.
Read the full article to get the code ^_^
———————————-snip——————————–
string tod = “am”;
integer hour = 3600;
integer minute = 60;
default
{
state_entry()
{
vector sun_angle =llGetSunDirection()*llEuler2Rot();
sun_angle.z = 0;//vertical filter
sun_angle = llVecNorm(sun_angle);//some more cleaning
float angle = llAcos(sun_angle.y/1)*RAD_TO_DEG;
//convert the coords of the sun to angle
if(sun_angle.x <0)//if we use the evening part of the quadrant
{
angle = 180 - angle;
tod = "pm";//switch to pm
}
float time = angle * 240;//convert in seconds
integer hours = (integer)(time/hour);//extract hours
time -= hour*hours;//substract seconds used by hours
string minutes = (string)((integer)(time/minute));//extract minutes
if( llStringLength(minutes) == 1 )//add a 0 to values of 1 digit
minutes = "0"+minutes;
llSetText((string)hours+":"+minutes+tod,<1,1,1>,1.0);
llSleep(5.0);//sun is updated every 10 seconds
llResetScript();
}
}
———————————-snip——————————–