Jump to content

Digital Clock with ability to change hour (timezone)


Pinky Vought
 Share

You are about to reply to a thread that has been inactive for 1456 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

I've made both analog and digital clocks with scripts found on the lsl wiki. The analog clock can be clicked on the right or left face side to decrease or increase the hour. I want to be able to do that with the digital clock as well. I know it's possible because I have an old clock that I purchased years ago with the ability, but the maker seems to have left SL or I'd ask him. My clock is nice, but only displays SL time.

I apologize if this is redundant, I searched and see many clock threads, but none that seem to cover my question. I've searched around and am not finding the script I need.

Any help? Thanks.

 

 

Link to comment
Share on other sites

Error?  I have been using that script for years.  Double check that you didn't make a copy/paste error, possibly by using a text editor that adds its own transparent formatting codes.  In any case, the important part is that one line that I copied earlier. That's the offset from GMT to PST.  Make a similar change in your own clock's script for the offset from GMT ( or PST) to your own time zone.  Assuming that your script makes its own proper adjustments at midnight, that should be all that's necessary.

Edited by Rolig Loon
Link to comment
Share on other sites

dunno if this helps, but here is an old clock thing with a variable to change the hour...

( this clock is set to SL time (PST) by default )

 

////////////////////////////////////////////
// Single Prim Clock v2.1 Script
//
// Written by Xylor Baysklef
////////////////////////////////////////////

/////////////// CONSTANTS ///////////////////
// These are the faces to show the clock on.
integer HOUR_FACE   = 4;
integer MINUTE_FACE = 0;
integer AM_PM_FACE  = 2;

// Texture type enumeration.
integer WHITE_ON_BLACK  = 0;
integer BLACK_ON_WHITE  = 1;
integer TRANSPARENT     = 2;

// This is the type of texture to display.
integer DISPLAY_TYPE    = WHITE_ON_BLACK;

list    HOUR_TEXTURES   = [
            // White on Black
            "7bc19746-de1b-b84c-9d2a-515d38c030ab",
            // Black on White
            "d9b1de36-44d6-c89b-7b7f-97cbc62d47a3",
            // Transparent
            "db0b0013-f0b5-70b3-5e40-8685d024a3a2" ];
            
list    MINUTE_TEXTURES = [
            // White on Black
            "9bc9c4bb-8c20-b103-fd5d-60f1072a39b1", // 00-29
            "e82c651f-47e9-7950-ea65-f496e1917dd4", // 30-59
            // Black on White
            "7d53ead7-e6a7-59c5-b98b-fe46d9f61818", // 00-29
            "6ae5d6a8-a78f-b505-e950-fcb003a480bf", // 30-59
            // Transparent
            "34e55b37-1c59-4a09-38d1-4150ffa396a5", // 00-29
            "2b660a82-8d91-c892-a076-45c4a86f0235"];// 30-59
            
list    AM_PM_TEXTURES  = [
            // White on Black
            "13c95970-27a7-1a7a-cbc4-0e93f00361ba",
            // Black on White
            "b4d9d87e-36f8-7f4f-7d11-b7a2e973053b",
            // Transparent
            "f4ca9c46-3a46-6986-eb42-f497e9898d7a" ];
///////////// END CONSTANTS ////////////////

///////////// GLOBAL VARIABLES ///////////////
integer timezone_Offset = 0;  // < ********************************** set timezone offset here *************************
/////////// END GLOBAL VARIABLES ////////////

UpdateTime() {
    // Get the time, and split it up into hours and minutes.
    float   Seconds = llGetWallclock();
    integer Minutes = llRound(Seconds / 60);
    integer Hours   = Minutes / 60;
    Hours +=  timezone_Offset; // < ****************************** changes the hour depending on timezone ******************
    
    // First, lets use this information to set up another
    // timer event (we do this every minute to eliminate
    // 'time drift' associated with just a single 60 second
    // timer event).
    float SecondsToNextMinute = Minutes * 60 - Seconds + 60;
    llSetTimerEvent(SecondsToNextMinute);
    
    // Now only keep the minutes of the current hour.
    // (Normalize to 0-59).
    Minutes %= 60;
    
    Hours %= 24;
    
    // Calculate if this is AM or PM.
    integer AM_PM = Hours / 12;
    
    // Normalize the hour to 0-11.
    Hours %= 12;
    
    // Calculate the hour grid positions.
    integer xHourPos = Hours % 4;
    integer yHourPos = Hours / 4;
    
    // Calcualte the minute texture index. 
    integer MinuteTextureIndex = DISPLAY_TYPE * 2 + Minutes / 30;
    
    // Normalize the minutes to 0-29.
    Minutes %= 30;
    
    // Calculate the minute grid positions.
    integer xMinutePos = Minutes % 5;
    integer yMinutePos = Minutes / 5;
    
    // Update the minute texture.
    key MinuteTexture = llList2Key(MINUTE_TEXTURES, MinuteTextureIndex);
    llSetTexture(MinuteTexture, MINUTE_FACE);
    
    // Now update the offsets to show the current time on the textures.
    llOffsetTexture(-0.40 + 0.20 * xMinutePos, 0.45 - 0.10 * yMinutePos, MINUTE_FACE);
    llOffsetTexture(-0.375 + 0.250 * xHourPos, 0.375 - 0.25 * yHourPos,  HOUR_FACE);
    llOffsetTexture(0, 0.250 - 0.50 * AM_PM, AM_PM_FACE);
}

default {
    state_entry() 
    {   llSetText("", <0.0, 1.0, 0.0>, 1.0);
        // First set up the correct texture scales, and rotations.
        llScaleTexture(0.25, 0.25, HOUR_FACE);
        llScaleTexture(0.20, 0.10, MINUTE_FACE);
        llScaleTexture(1.00, 0.50, AM_PM_FACE);
        llRotateTexture(PI_BY_TWO, HOUR_FACE);
        llRotateTexture(0,         MINUTE_FACE);
        llRotateTexture(-PI_BY_TWO,AM_PM_FACE);
        
        // Show the hour and am/pm textures, since they don't change.
        llSetTexture(llList2Key(HOUR_TEXTURES, DISPLAY_TYPE), HOUR_FACE);
        llSetTexture(llList2Key(AM_PM_TEXTURES, DISPLAY_TYPE), AM_PM_FACE);
        
        // Now just update the time, it will also start the timer.
        UpdateTime();
    }
    
    on_rez(integer param) {
        UpdateTime();
    }
    
    timer() {
        // This will show the time, and adjust the timer event.
        UpdateTime();
    }
}

 

Edited by Xiija
  • Thanks 1
Link to comment
Share on other sites

That's cool. The old clock that I have has a menu for the user to click to increase or decrease the hour to the desired setting. I want that, lol, but don't know how to incorporate it into this script I have. It's more complicated than the analog script.

Here is the script I'm using. The first one is in the main prim, the other is in each of the 4 digital display prims-

integer first_number = 2;
integer digits = 4;
integer mil = 0;

setTime(string time)
{
    integer len = llStringLength(time);
    integer i;
    for (i = 0; i < digits; i++)
    {
        if (i < len)
        {
            integer number = (integer)(llGetSubString(time, len - 1 - i, len - 1 - i));
            llMessageLinked(first_number + i, number, "", "");
        } else
        {
            llMessageLinked(first_number + i, -1, "", "");
        }
    }
}

default
{
    state_entry()
    {
        llSetStatus(STATUS_PHANTOM | STATUS_BLOCK_GRAB, TRUE);
//        llListen(8877661, "timekeeper", "", "");
        llSetTimerEvent(1);
        llMessageLinked(LINK_ALL_CHILDREN, -1, "", "");
        llListen(2257,"","","");
    }

    listen(integer ch, string name, key id, string msg)
    {
        if (msg == "mil") mil = 1;
        if (msg == "std") mil = 0;
    }

    timer()
    {
        integer hh;
        integer mm;
        float time = llGetWallclock();
//        float time = llGetTimeOfDay();
        string score;
        hh = (integer)time / 3600;
        mm = ((integer)time % 3600) / 60;
        hh = hh % 12;
        if (mil == 0 && hh > 12)
        {
            hh = hh - 12;
            llWhisper(2258,"PM");
        } else
        {
            if (mil == 0)
            {
                if (hh == 0) hh = 12;
                llWhisper(2258,"AM");
            } else
            {
                llWhisper(2258,"mil");
            }
        }
        score = (string)hh;
        if (mm < 10)
        {
          score = score + "0" + (string)mm;
        } else
        {
          score = score + (string)mm;
        }
        if (((integer)time % 2) == 0)
        {
            llWhisper(2259,"<1,0,0>");
        } else
        {
            llWhisper(2259,"<0.23,0.01,0.02>");
        }
        setTime(score);
    }
}

 

And-

//
//  Digit
//  
//  Implements one character of a digital display
//
 
integer FACE = 0;               //  Which face to display value on
integer value = 0;                    

display()
{
    if (value == -1)
    {
        llSetTexture("null", FACE);
    }
    if (value == 0)
    {
        llSetTexture("zero", FACE);
    }
    else if (value == 1)
    {
        llSetTexture("one", FACE);
    }
    else if (value == 2)
    {
        llSetTexture("two", FACE);
    }
    else if (value == 3)
    {
        llSetTexture("three", FACE);
    }
    else if (value == 4)
    {
        llSetTexture("four", FACE);
    }
    else if (value == 5)
    {
        llSetTexture("five", FACE);
    }
    else if (value == 6)
    {
        llSetTexture("six", FACE);
    }
    else if (value == 7)
    {
        llSetTexture("seven", FACE);
    }
    else if (value == 8)
    {
        llSetTexture("eight", FACE);
    }
    else if (value == 9)
    {
        llSetTexture("nine", FACE);
    }
}
default
{
    state_entry()
    {
        llSetStatus(STATUS_BLOCK_GRAB, TRUE);
        llPassTouches(TRUE);
    }
   
    link_message(integer who, integer num, string str, key id)
    {
        integer new_value = num;
        if (new_value != value)
        {
            value = new_value;
            display();
        }
    }
 
}

 

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

I suggest trying it both ways (after first making backup copies of everything in case you guess wrong).  My best guess, though, is that you want the clock and all of its scripts to be in child prims, not in the root.  The problem you are likely to have, either way, is that the script may not be able to identify the prims that you are using to display the time.  If that happens, take extra steps to include code that will identify those prims by name and then address them directly in your script.

Link to comment
Share on other sites

  • 1 year later...

 

On 12/10/2018 at 1:19 PM, Rolig Loon said:

I suggest trying it both ways (after first making backup copies of everything in case you guess wrong).  My best guess, though, is that you want the clock and all of its scripts to be in child prims, not in the root.  The problem you are likely to have, either way, is that the script may not be able to identify the prims that you are using to display the time.  If that happens, take extra steps to include code that will identify those prims by name and then address them directly in your script.

 Good afternoon,  I searched "TimeZone" and your post came up.  I know nothing about scripts.  If you can, would you please help me?  I think my question is pretty simple.  How can I have my SLT the same as my RL time, Pacific Stand Time?   I always get dark, night, hours.  When I changed the setting under "Environment" it gives me one fixed time and never changed.   I don't recall I had to change timezone or anything when I was at the old Theme.  It probably only happened when I started with Bellisserie.   (I apologize if I post my question in the wrong thread.)

Link to comment
Share on other sites

The difference between your local time and SLT is a simple offset, so you approach it the same way that you would if you were calculating the difference manually. If you were in the Central time zone (USA), then the difference between CST and PST (that is, SLT)  would be 2 hours.  So, wherever the script determines SLT, you just add two hours to get CST.  I'm obviously missing something in your question, though, since you said that you live in the Pacific Standard time zone.  If that's the case, there is NO offset.  Your clock is already telling you the correct local time.

I can't give you a more satisfactory answer than that without knowing what your script looks like and without understanding the question better, so I suggest posting in the InWorld Employment forum to attract a scripter who would be willing to take a look at the script for you.

  • Thanks 1
Link to comment
Share on other sites

Sophia, if you mean how to change the EEP time so you get day light rather than night time, when you usually log in to your home parcel then we can do this with our parcel controls

in Linden viewer:  menu: World \ About Land \ Environments \ Day Offset (hours)

move the Day Offset hours slider left or right to change the EEP time

underneath the Day Offset slider it tells us the Apparent Time of Day. Move the Day Offset slider til you get it about right for yourself

 

  • Thanks 1
Link to comment
Share on other sites

53 minutes ago, Rolig Loon said:

The difference between your local time and SLT is a simple offset, so you approach it the same way that you would if you were calculating the difference manually. If you were in the Central time zone (USA), then the difference between CST and PST (that is, SLT)  would be 2 hours.  So, wherever the script determines SLT, you just add two hours to get CST.  I'm obviously missing something in your question, though, since you said that you live in the Pacific Standard time zone.  If that's the case, there is NO offset.  Your clock is already telling you the correct local time.

I can't give you a more satisfactory answer than that without knowing what your script looks like and without understanding the question better, so I suggest posting in the InWorld Employment forum to attract a scripter who would be willing to take a look at the script for you.

 

20 minutes ago, Mollymews said:

Sophia, if you mean how to change the EEP time so you get day light rather than night time, when you usually log in to your home parcel then we can do this with our parcel controls

in Linden viewer:  menu: World \ About Land \ Environments \ Day Offset (hours)

move the Day Offset hours slider left or right to change the EEP time

underneath the Day Offset slider it tells us the Apparent Time of Day. Move the Day Offset slider til you get it about right for yourself

 

Thank both of your replies to your best understand of my question.  It's appreciated.

In combining of of your comments:

1.  Correct.  I should not need to offset hours because I was told that SLT and PDT is in the same timezone.  But, the apparent time of day was different than my timezone when I click "about land, Environment, and come to the page".  I might have made change which i can't recall.

2. I took photo of what was before and after I made adjustment on the Day Offset handle.

3.   BEFORE:  PDT 2:48 PM VS. 10:52 AM.

4.  AFTER:  PDT 2:51 PM VS. 2:10 AM

after I drag the handle to the very left, it seems the time inworld is very close to my rl timezone.  I know nothing about scripts and am afraid to touch and make it worse. 

So I hope I am going to have the same timezone in both RL and SL from now on. 

after.png

Before.png

Link to comment
Share on other sites

2 minutes ago, SophiaJoy Langsdorff said:

 

I should not need to offset hours because I was told that SLT and PDT is in the same timezone

 

yes this is true. SLT is PDT

the day cycle we see on our screen is not aligned with SLT time.  Before EEP the Windlight day cycle was a region setting. with EEP is now a parcel setting as well

and on Linden mainland, regions next to each other could have different day cycles.  Day time on a region, move to the nextdoor region then night time

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1456 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...