Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help!!

Almia Thaler
IMA Shyguy!! 0o0
Join date: 3 Jun 2008
Posts: 173
06-26-2008 12:35
I'm looking for a clock script that uses the llGetGMTclock() command but has time zone dilation ability so my users can set their respective time zones.

any help on this would be greatly appreciated.
Klug Kuhn
Registered User
Join date: 7 Sep 2007
Posts: 126
07-03-2008 01:37
That's in fact free in the library. But i copy & paste them here.

How to use?
1) make a prim, new script it, replace the "XyTextPrim Setup" script into its content.
2) new another script, replace the "Single Prim Clock v2.1 Script" into this 2nd script.
3) it's all ready to use. When you wanna change the timezone, change the prim's description.

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









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