Hover Text Clock

// HoverText Clock Script
// By Ben Linden
//
// Drop on an object to make it display the PST time.
//
// If you are interested in scripting, check out
// the Script Help under the help menu.

// The double slash means these lines are comments
// and ignored by the computer.




// Global Variables
// a string is a collection of characters.
string smin; // Represents minutes
string sseconds; //Represens seconds

// All scripts have a default state, this will be
// the first code executed.
default
{
    // state_entry() is an event handler, it executes
    // whenever a state is entered.
    state_entry()
    {
        // llSetTimerEvent() is a function that sets 
        // up a timer event in seconds.
        llSetTimerEvent(2.0);  // call a timer event 
                               // every 2 seconds.
    }
    
    
    // timer() is an event handler, it executes on an
    // interval defined by llSetTimerEvent()
    timer()
    {
       // llFloor is a function that rounds down all numbers.
       // llGetWallClock is a function that returns the time 
       // of day in seconds, on a 24 hour clock.
       integer seconds =  llFloor(llGetWallclock());
       // Convert the total number of seconds into a integer (whole number)
       integer min = llFloor(seconds/60);
       // Figure out how many minutes that is
       seconds = seconds - (min*60);
       //Work out the remaining number of seconds
       integer hour = llFloor(min/60);
       // figure out how many hours it represents.
       min = min - (hour*60);
       // figure out the number of minutes remaining
       
       // if is a conditional statement, it will only execute if the conditions are met. 
       if(hour > 12) {hour = hour - 12;} // if the hours are greater than 12, convert to 12 hour time
       string shour = (string)hour; //convert the number into a string
       if(min <10) {smin = "0"+(string)min;} // if less than 10 minutes, put a 0 in the minute string
       else { smin = (string)min;} 
       if(seconds < 10) { sseconds = "0"+(string)seconds;} // if less than 10 sec, put a 0 in the second string
       else {sseconds = (string)seconds;}
       
       
       string time = shour + ":" + smin + ":" + sseconds; // build the seperate strings into a complete string, with colons
       
       // llSetText is a function that displays a string over the object.
       llSetText(time, ZERO_VECTOR, 1.0); //Display the string in solid black.
    }

}

 

Binary Clock v1.1

// Binary Clock Script
// By Fox Diller
// OMG INSANITY!
 
list bTime;
list oTime;
 
integer token;
 
string dec2bin(integer dec)
{
    return llGetSubString("0000,0001,0010,0011,0100,0101,0110,0111,1000,1001", dec * 5, dec * 5 + 3);
}
 
BuildClock()
{
    integer shiftraw = (integer)llGetWallclock();
 
    integer hours = shiftraw / 3600;
    integer minutes = (shiftraw % 3600) / 60;
    integer seconds = shiftraw % 60;
 
    bTime = [hours / 10, hours % 10,
        minutes / 10, minutes % 10,
        seconds / 10, seconds % 10];
}
 
SendDigitsToLinks(string str, integer link, integer len)
{
    integer x = 3;
    while(len--)
    {
        llMessageLinked(link++, (integer) llGetSubString(str, x, x) , "", "");
        --x;
    }
}
 
displayBDC()
{
    integer current_rowA = llList2Integer(bTime, 0);
    if (current_rowA != llList2Integer(oTime, 0) )
    {
        string rowA = dec2bin(current_rowA);
        SendDigitsToLinks(rowA, 2, 2);
    }
    else if (!current_rowA) 
        SendDigitsToLinks("00", 2, 2);
 
    integer current_rowB = llList2Integer(bTime, 1);
    if (current_rowB != llList2Integer(oTime, 1))
    {
        string rowB = dec2bin(current_rowB);
        SendDigitsToLinks(rowB, 4, 4);
    }
    else if (!current_rowB)
        SendDigitsToLinks("0000", 4, 4);
 
    integer current_rowC = llList2Integer(bTime, 2);
    if (current_rowC != llList2Integer(oTime, 2))
    {
        string rowC = dec2bin(current_rowC);
        SendDigitsToLinks(rowC, 8, 3);
    }
    else if (!current_rowC)
        SendDigitsToLinks("000", 8, 3);
 
    integer current_rowD = llList2Integer(bTime, 3);
    if (current_rowD != llList2Integer(oTime, 3))
    {
        string rowD = dec2bin(current_rowD);
        SendDigitsToLinks(rowD, 11, 4);
    }
    else if (!current_rowD)
        SendDigitsToLinks("0000", 11, 4);
 
    integer current_rowE = llList2Integer(bTime, 4);
    if (current_rowE != llList2Integer(oTime, 4))
    {
        string rowE = dec2bin(current_rowE);
        SendDigitsToLinks(rowE, 15, 3);
    }
    else if (!current_rowE)
        SendDigitsToLinks("000", 15, 3);
 
    integer current_rowF = llList2Integer(bTime, 5);
    if (current_rowF != llList2Integer(oTime, 5))
    {
        string rowF = dec2bin(current_rowF);
        SendDigitsToLinks(rowF, 18, 4);
    }
    else if (!current_rowF)
        SendDigitsToLinks("0000", 18, 4);
}
 
MessageLinked(integer inputLinkNumber, integer inputNumber)
{
    llMessageLinked(inputLinkNumber, inputNumber, "", "");
}
 
default
{
    touch_start(integer total_number)
    {
        if (llDetectedKey(0) != llGetOwner() )
            return;
        if ( !(token = !token) )
            llOwnerSay("Off!");
        else
        {
            oTime = bTime = [];
            llOwnerSay("On!");
        }
        llSetTimerEvent(token);
    }
 
    timer()
    {
        bTime = oTime;
        BuildClock();
        displayBDC();
    }
}

 

Touch Time Advanced

Have 2 different things happen for regular Touch and Long Touch, (hold for 2 seconds.) 

If avatar Touches like normal they get TOUCH 1

If avatar Touches and holds for 2+ seconds they get TOUCH 2

 

 

float mintime = 2.0; //how many seconds to get long touch option

float t;
integer donenow = FALSE;
 
default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
    
    state_entry()
    {
        donenow = FALSE;
    }
    
    touch_start(integer num_detected)
    {
        t = llGetTime();
    }
    
    touch(integer num_detected)
    {
        float tempsecs = llGetTime() - t;
        if ((tempsecs >= mintime) && (donenow == FALSE))
        {
            donenow = TRUE;
            llSay(0, "Long Touch detected, you may release Touch now.");
        }
    }
    
    touch_end(integer num_detected)
    {
        float secs = llGetTime() - t;
        //llOwnerSay((string)secs + " seconds between touch_start and touch_end"); //debug
        if (secs >= mintime) //greater than or equal
        {
            llSay(0, "Touch 2"); //debug
        }
        else //regular touch
        {
            llSay(0, "Touch 1"); //debug
        }
        donenow = FALSE;
    }
}

 

 

 

Analog Clock ( V1 )

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);
            }
        }
    }
}

 

Touch Time Basic

Will tell you how many seconds between Touch_Start and Touch_End. 

 

float t;
 
default
{
    touch_start(integer num_detected)
    {
        t = llGetTime();
    }
    
    touch_end(integer num_detected)
    {
        llOwnerSay((string)(llGetTime() - t) + " seconds between touch_start and touch_end");
    }
}