Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Basic Mechanical Clock Script

Phoenix Ristow
Registered User
Join date: 11 Sep 2006
Posts: 9
05-19-2007 01:33
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);
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
05-23-2007 22:21
/54/75/185978/1.html
_____________________
i've got nothing. ;)
Erik Bligh
Registered User
Join date: 25 Feb 2006
Posts: 27
05-26-2007 07:50
This script has some syntax errors
Azildin Furst
Registered User
Join date: 14 Jan 2007
Posts: 6
08-17-2007 23:50
This does not work when I copy and paste into SL. It just gives me a lot of syntax errors.