CODE
//HINT: Set up your clock face then dupliate that prim and reshape for a clock hand
//Use a hand texture that is the hand on one side and total invis on the other so your
//hand rotates around the center of the face and you avoid rotation issues. Set your
// hands to 12am...turn on the script and it iwll automatically set the hands to SL time on
// startup. Enjoy.
//uncomment the type of hand this piece is - second,minute, hour
//integer hand_type =1;//seconds
//integer hand_type =2;//minutes
//integer hand_type =3;//hours
//do not edit below
integer t;
integer hours;
integer minutes;
integer seconds;
integer time_interval;
integer rot_num;
rotation hand_rot;
rotation start_rot;
Set_Hand(){
integer x = time_interval;
for(x=0;x < time_interavl + 1;x++)
{
rotation rot = llGetLocalRot();
rotation delta = llEuler2Rot(<0,0, PI/rot_num>);
rot = delta * rot;
llSetLocalRot(rot);
}
hand_rot = llGetLocalRot();
llSetTimerEvent(60.0);
}
default
{
state_entry()
{
llListen(0,"",llGetOwner(),"");
hand_rot = llGetLocalRot();
start_rot = llGetLocalRot();
t = (integer)llGetWallclock();
hours = t / 3600;
minutes = (t % 3600) / 60;
seconds = t % 60;
if(hand_type==1)
{
time_interval = seconds;
rot_num = 30;
}
else if (hand_type-==2)
{
time_interval=minutes;
rot_num=30;
}
else
{
time_interval=hours;
rot_num = 6;
}
Set_Hand();
}
listen(integer channel,string name,key id,string message)
{
if(llToLower(message)=="resetclock")
{
llSetLocalRot(start_rot);
llResetScript();
}
}
timer()
{
rotation rot = llGetLocalRot();
rotation delta = llEuler2Rot(<0,0, PI/rot_num>);
rot = delta * rot;
llSetLocalRot(rot);
}
}