Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Single Prim Clock

Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
03-10-2004 18:13
Here is a clock that can display the time on just one prim. Useful if you want to conserve prims, or you just want a quick and simple clock in a project.

To use, first create a box with the follow dimensions:

Size:
X -> 1.000
Y -> 0.250
Z -> 0.010

Top Size:
X -> 0.33
Y -> 1.00

Then throw this script onto it:

CODE

////////////////////////////////////////////
// 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 = BLACK_ON_WHITE;

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 ///////////////
/////////// 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;

// 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() {
// 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();
}
}


Have fun ^_~

Xylor
Jinx Pasteur
Junior Member
Join date: 1 Feb 2004
Posts: 2
03-23-2004 09:26
Xylor, great clock. I changed the face color to match my decor (caution yellow) and put one up in my Stinson laboratory so I'll have no excuse staying up til 3AM playing with prims. My poor, tired eyes thank you. :-D
_____________________
-----------------------------------------

Q: What was wrong with the restaurant on the moon?
A: It didn't have any atmosphere.
Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
03-24-2004 16:47
Thanks Jinx, glad its getting some use =)

Xylor
The Hannibal
Junior Member
Join date: 25 Mar 2004
Posts: 5
or you could..
03-29-2004 04:03
Could just do this :)

CODE

default
{
state_entry()
{
key owner = llGetOwner();
llWhisper(0,"Cloaking ready");
llListen(0,"",owner,"");
}

listen( integer channel, string name, key id, string message )
{
if( message == "cloak" )
{
llSetStatus(STATUS_PHANTOM, TRUE);
llWhisper(0,"Cloaking");
llSetAlpha(0,ALL_SIDES);
}
if( message == "uncloak" )
{
llSetStatus(STATUS_PHANTOM, FALSE);
llWhisper(0,"Uncloaking");
llSetAlpha(1,ALL_SIDES);
}
}
}
Adam Marker
new scripter
Join date: 2 Jan 2004
Posts: 104
03-31-2004 22:19
I like the clock -- thanks! I would also like to know more about how it works. I know the various constants point to the textures, but where do those textures live? If they are from some standard texture library for the world, is there a reference catalog of them somewhere?
Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
04-03-2004 14:09
The textures 'live' on the asset server. After I uploaded them, I took the UUID (basically the key to the texture on the asset server) and used those as constants in the script. This lets me distribute the script without having the correct texture in the Contents area of the object.

The original textures are available however, if you want to take a look at them. I put them in Hank Ramos' SL Script Forum Repository, at Clara (162, 131), in the Time scripts box. (They in the individual prims of the "Time Texture Grid" object).

Xylor
Beli Taggart
Registered User
Join date: 8 Feb 2006
Posts: 3
02-24-2006 21:50
I did a simple modification to the script to do offsets for timezones:

CODE

////////////////////////////////////////////
// Single Prim Clock v2.1 Script
//
// Written by Xylor Baysklef
// Modified by Beli Taggart 02/25/06
// - Added an offset for different timezones.
////////////////////////////////////////////

/////////////// 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 = BLACK_ON_WHITE;
integer TIME_OFFSET = 3; // 0 = PST, 1 = MST, 2 = CST, 3 = EST, etc etc - Beli

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 ///////////////
/////////// 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) + TIME_OFFSET; // Modify the actual hour to the offset - Beli



// 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() {
// 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();
}
}


Just modify the TIME_OFFSET line to your timezone (I live in EST so it'd be 3)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
02-25-2006 08:19
/15/64/10739/1.html
_____________________
i've got nothing. ;)
Ghoti Nyak
καλλιστι
Join date: 7 Aug 2004
Posts: 2,078
03-06-2006 19:00
Fun toy :)

-Ghoti
_____________________
"Sometimes I believe that this less material life is our truer life, and that our vain presence on the terraqueous globe is itself the secondary or merely virtual phenomenon." ~ H.P. Lovecraft
perttu Kitty
I was here?
Join date: 17 Dec 2004
Posts: 23
03-24-2006 07:57
OMG Thank you Beli Taggard!! I've been running around everywhere looking for a clock that showed EST for ever now!! =^_^=
_____________________
There's enough hatered in the world we don't need any on Second Life.
Cade Jae
Registered User
Join date: 5 Dec 2006
Posts: 2
01-19-2008 13:29
Trying to understand how this works. Textures for hours, minutes, am/pm show on separate faces ... but I assume all 3 are intended to be visible on the same side of the object. Trying to understand what "Top Size" x=.33, y=1 refers to in the box paramaters for the build. I only see entries for "Top Shear" and these are limited to values of x,y <= 0.5. What am I missing in order to get the box "squished" to show three textures (faces) all from one side of the object?

thanks! -cade
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-19-2008 14:04
My understanding is that those would be taper values (or one minus taper values). So looking from the positive z-axis ("on top";), there would be three sides visible, each taking up a third of the area of the profile.
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
01-19-2008 14:26
I used this script to set up the prim first.

-----------------

////////////////////////////////////////////
// XyText Prim Setup
//
// Written by Xylor Baysklef
////////////////////////////////////////////

/////////////// CONSTANTS ///////////////////
// Transparent texture key.
string TRANSPARENT = "701917a8-d614-471f-13dd-5f4644e36e3c";

default {
state_entry() {
// Set up the prim to be the correct shape.
vector Scale = llGetScale();
llSetPrimitiveParams([
// Set the top size so this shows 3 faces at once.
PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0, 1, 0>, 0.0, ZERO_VECTOR, <0.333333, 1, 0>, ZERO_VECTOR,

// Display the string "XyText" for now.
PRIM_TEXTURE, 4, "0e47c89e-de4a-6233-a2da-cb852aad1b00",
<0.1, 0.1, 0>, <0.200000, -0.450000, 0.000000>, PI_BY_TWO,

PRIM_TEXTURE, 0, "20b24b3a-8c57-82ee-c6ed-555003f5dbcd",
<0.1, 0.1, 0>, <-0.200000, -0.450000, 0.000000>, 0.0,

PRIM_TEXTURE, 2, "2f713216-4e71-d123-03ed-9c8554710c6b",
<0.1, 0.1, 0>, <-0.050000, -0.350000, 0.000000>, -PI_BY_TWO,

// Show transparent textures for the other sides.
PRIM_TEXTURE, 1, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 3, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 5, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,

// Set the correct aspect ratio.
PRIM_SIZE, <Scale.x, Scale.x / 3, 0.01>
]);

// Remove ourselves from inventory.
llRemoveInventory(llGetScriptName());
}
}
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
01-19-2008 16:14
Xylor, Do you think you could repost this without all the [/color][/i] tags. It would take a lot of work to remove all those to get a useful script.
Thanks
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
01-19-2008 16:19
Sorry:

I guess Beli's version takes care of that.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-19-2008 19:43
In case anyone is interested here is the script as it was originally posted before bbcode (or lack of) borked it. Had it in my Scite folder from waaaaay back:

CODE

////////////////////////////////////////////
// Single Prim Clock v2.1 Script
//
// Written by Xylor Baysklef
// Modified by Beli Taggart 02/25/06
// - Added an offset for different timezones.
////////////////////////////////////////////
//Prim Setup
//Size (1.0,0.25,0.01) Taper X (0.66)
/////////////// 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 = TRANSPARENT;
integer TIME_OFFSET = 3; // 0 = PST, 1 = MST, 2 = CST, 3 = EST, etc etc - Beli

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 ///////////////
/////////// 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) + TIME_OFFSET; // Modify the actual hour to the offset - Beli



// 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() {
// 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();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Cade Jae
Registered User
Join date: 5 Dec 2006
Posts: 2
01-19-2008 23:15
Brilliant! got it! Thank you very much for the explanation Hewee and also to Dina for posting Xylor's prim setup script ... learned even more :) Great to have in the toolbox. I wouldn't have figured out the taper values (1-value). thanks again for your (speedy) replies

- cade
Gordon Wendt
404 - User not found
Join date: 10 May 2006
Posts: 1,024
01-20-2008 01:29
Absolutely great, I just replaced all of my conventional XYZText board clocks (using the same method that signboards are made of meaning a huge number of generally wasted prims) with these new clocks, I'd suggest updating the OP though to reflect the improvements including the offset settings which was a great idea.
_____________________
Twitter: http://www.twitter.com/GWendt
Plurk: http://www.plurk.com/GordonWendt

GW Designs: XStreetSL

Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-20-2008 16:26
I've added text formating tag support in code tags to my bbcode script so it will parse the above script. Sorry for not doing it sooner, didn't realize it was legal.
http://userscripts.org/scripts/show/9651
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-20-2008 18:22
nice, I'll add it to the sticky in scripting library... btw is there some weirdness in how it processes embedded images? occasionally I have to disable it to see some images posted in the forums
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-20-2008 18:59
From: Void Singer
nice, I'll add it to the sticky in scripting library... btw is there some weirdness in how it processes embedded images? occasionally I have to disable it to see some images posted in the forums

Are you using Opera or Firefox? Opera handles the timing of loading a page and implemented the java code differently then Firefox does. Every now and then Opera screws it up.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-20-2008 23:56
Firefox =/

/hijack
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
01-21-2008 02:19
A Minor update to further internationalise the clock.
Expanding on Beli Taggart's Idea. I set the base clock to GMT
(Note it will no longer correct for Daylight Saving.)
It will now read the Time offset from the Object description Field so that
The Time zone can be adjusted without having to edit the script.

CODE

////////////////////////////////////////////
// Single Prim Clock v2.1 Script
//
// Written by Xylor Baysklef
// Modified by Beli Taggart 02/25/06
// - Added an offset for different timezones.
// Modified By Very Keynes 01/25/07 to further Internationalise
// - Changed Base Clock to GMT time
// - Reads Time Zone from Description Field
// i.e +2=Cape Town / South Africa
// or +10=Sydney / Australia
// or –7=Mountain Time (USA/Canada)
////////////////////////////////////////////

/////////////// 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 = BLACK_ON_WHITE;
integer TIME_OFFSET = 0; // 0 = GMT, 1 = MST, 2 = CST, 3 = EST, etc etc - Beli

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 ///////////////
/////////// END GLOBAL VARIABLES ////////////

UpdateTime() {
// Get the time, and split it up into hours and minutes.
float Seconds = llGetGMTclock();
integer Minutes = llRound(Seconds / 60);
TIME_OFFSET = (integer)llGetSubString(llGetObjectDesc(),-1,llSubStringIndex(llGetObjectDesc(),"=")); //Very Keynes
integer Hours = (Minutes / 60) + TIME_OFFSET; // Modify the actual hour to the offset - Beli



// 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() {
// 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();
}
}


A Useful list of time zones may be found here:
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
01-21-2008 07:24
I wonder how hard it is to add an option to display the time in international format as well so that 7:30 PM will display as 19:30?
Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
02-26-2009 18:39
Why is Am and PM not working right for me? Set it for -6 hours and 8 PM at night and get AM.
1 2