Analog Clock ( V1 )

Written by Kitsune

Simple analog clock with hourly chimes (if desired) that by default shows GMT but can by simply clicking the object be adjusted by hour to show any global timezone.

 

  • The first script is used to build the object. Some manual prim editing is required but very little. This includes the naming of the hands.
  • The second script runs the clock.

 

Clock Maker

 

  • Create a link_set of 6 prims.
  • Drop this script on it.

 

// V2 //
 
default
{
    state_entry()
    {
        if(llGetObjectPrimCount(llGetKey()) == 6)
        {
            llSetLinkPrimitiveParamsFast(1, [5,1,7,<1.0, 1.0, 0.02>,
                                             8,<0.0, 0.0, 0.0, 1.0>,
                                             9,0,0,<0.0, 1.0, 0.0>,0.0,<0.0, 0.0, 0.0>,<0.95, 0.95, 0.0>,<0.0, 0.0, 0.0>,
                                             17,0,"ecf785e7-4cf6-9f95-6292-40061bdddeed",<0.7, 0.7, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             17,1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             17,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             17,3,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             17,4,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             17,5,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             18,-1,<0.6745, 0.6745, 0.7255>,1.0,
                                             19,0,3,1,
                                             19,1,3,0,
                                             19,2,3,0,
                                             19,3,3,0,
                                             19,4,3,0,
                                             19,5,3,0,
                                             20,0,1,
                                             20,1,0,
                                             20,2,0,
                                             20,3,0,
                                             20,4,0,
                                             20,5,1,
                                             25,-1,0.012]);
            llSetLinkPrimitiveParamsFast(2, [6, <0.0,0.0,0.01>, 7,<0.16, 0.91, 0.91>,
                                             8,<0.0, 0.707107, 0.0, 0.707107>,
                                             9,3,0,<0.0, 1.0, 0.0>,0.0,<0.0, 0.0, 0.0>,<0.5, 1.0, 0.0>,
                                             17,-1,"e97cf410-8e61-7005-ec06-629eba4cd1fb",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             18,-1,<1.0, 1.0, 1.0>,1.0,
                                             19,-1,2,0]);
            llSetLinkPrimitiveParamsFast(3, [6, <0.0,0.0,0.02>, 7,<0.04, 0.6, 0.02>,
                                             8,<0.0, 0.0, 0.0, 1.0>,
                                             9,0,0,<0.375, 0.875, 0.0>,0.0,<0.0, 0.0, 0.0>,<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,
                                             17,-1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             18,-1,<0.0, 0.0, 0.0>,1.0,
                                             19,-1,1,0,
                                             25,-1,0.012]);
            llSetLinkPrimitiveParamsFast(4, [6, <0.0,0.0,0.06>, 7,<0.02, 0.4, 0.02>,
                                             8,<0.0, 0.0, 0.0, 1.0>,
                                             9,0,0,<0.375, 0.875, 0.0>,0.0,<0.0, 0.0, 0.0>,<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,
                                             17,-1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             18,-1,<0.5, 0.0, 0.0>,1.0,
                                             19,-1,1,0,
                                             25,-1,0.012]);
            llSetLinkPrimitiveParamsFast(5, [6, <0.0,0.0,0.04>, 7,<0.02, 0.8, 0.02>,
                                             8,<0.0, 0.0, 0.0, 1.0>,
                                             9,0,0,<0.375, 0.875, 0.0>,0.0,<0.0, 0.0, 0.0>,<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,
                                             17,-1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                                             18,-1,<0.0, 0.0, 0.0>,1.0,
                                             19,-1,1,0,
                                             25,-1,0.012]);
            llSetLinkPrimitiveParamsFast(6, [6, <0.0,0.0,0.01>, 7,<0.12, 0.06, 0.06>,
                                             8,<0.0, 0.707107, 0.0, 0.707107>,
                                             9,3,0,<0.0, 1.0, 0.0>,0.0,<0.0, 0.0, 0.0>,<0.5, 1.0, 0.0>,
                                             17,-1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.25, 0.0, 0.0>,0.0,
                                             18,-1,<0.675, 0.675, 0.7255>,1.0,
                                             19,0,3,0,19,1,3,0,19,2,3,0,
                                             25,-1,0.012]);
            llSetLinkPrimitiveParamsFast(1, [8,<0.707107, 0.0, 0.0, 0.707107>]);
            llRemoveInventory(llGetScriptName());
        }
        else
        llOwnerSay("Read the instructions");
    }
}

 

 

    https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">
  • When it has run, open an edit on the object and check the "Edit Linked Parts" checkbox.
  • Select the clear dome covering the face and path cut it to give easier editing access to the hands.
  • Select each hand one at a time and set the slice parameter to B : 0.400 E : 0.600
  • As you have the edit open for each, also name each hand as follows -
      https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); ">
    • Hour Hand - is the shorter of the two black hands.
    • Minute Hand - is the longer of the two black hands.
    • Second Hand - is the shortest.
        https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); ">
      • NAME THE HANDS EXACTLY AS THEY ARE WRITTEN HERE. Mind the capitals and spaces etc.
  • When those steps are complete, select the dome prim again and remove the path cutting.
  • The object is complete.

 

Clock Movement

 

    https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">
  • Drop this script onto the clock object.
  • As soon as the script runs it will start displaying the time GMT.
  • If a UUID has been set for chimes it will chime the hour (even if not zero minutes past) but from then on will only chime on the hour each hour.
  • To set the time to another timezone simply touch the clock and the time will increment by one hour.
  • Enjoy!

 

// V1 //
 
key chime = "79cdaa3c-43e9-63e7-d3c3-af6a14239452"; // Chime sound UUID. If empty no chime will sound.
 
float volume = 1.0; // Volume of chime.
 
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////IF YOU EDIT BELOW THIS LINE THE SCRIPT WILL EXPLODE/////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
 
integer second_hand_link;
 
integer minute_hand_link;
 
integer hour_hand_link;
 
float twelve = 43200.0;
 
integer last = -1;
 
integer offset;
 
integer chimes;
 
integer hour;
 
default
{
    on_rez(integer param)
    {
        llResetScript();
    }
    changed(integer change)
    {
        if(change & CHANGED_LINK)
        llResetScript();
    }
    state_entry()
    {
        integer nol = (llGetObjectPrimCount(llGetKey()) + 1);
        string link_name = "";
        while(--nol)
        {
            if((link_name = llGetLinkName(nol)) == "Second Hand")
            second_hand_link = nol;
            else if(link_name == "Minute Hand")
            minute_hand_link = nol;
            else if(link_name == "Hour Hand")
            hour_hand_link = nol;
        }
        llSetTimerEvent(1.0);
    }
    timer()
    {
        float seconds = (llGetGMTclock() + ((float)offset));
        rotation root_rot = llGetRootRotation();
        llSetLinkPrimitiveParamsFast(second_hand_link, [8, (llEuler2Rot(<0.0,0.0,(seconds * -6.0)> * DEG_TO_RAD) / root_rot)]);
        llSetLinkPrimitiveParamsFast(minute_hand_link, [8, (llEuler2Rot(<0.0,0.0,(seconds * -0.1)> * DEG_TO_RAD) / root_rot)]);
        llSetLinkPrimitiveParamsFast(hour_hand_link, [8, (llEuler2Rot(<0.0,0.0,(seconds * -0.008333)> * DEG_TO_RAD) / root_rot)]);
        if(chime)
        {
            if((!chimes))
            {
                if(seconds > twelve)
                {
                    if((seconds -= twelve) > twelve)
                    seconds -= twelve;
                }
                if((hour = llFloor((seconds / 3600.0))) != last)
                {
                    last = hour;
                    if((!hour))
                    hour = 12;
                    chimes = hour;
                }
            }
            if(chimes)
            {
                llPlaySound(chime, volume);
                --chimes;
            }
        }
    }
    touch_start(integer nd)
    {
        while(nd)
        {
            if(llDetectedKey((--nd)) == llGetOwner())
            {
                llSetTimerEvent(0.0);
                if((offset += 3600) == ((integer)twelve))
                offset = 0;
                chimes = 0;
                llSetTimerEvent(1.0);
            }
        }
    }
}