Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Clock Clock_Linkable  

Clock_Linkable

place this script in the "clock" prim

Category: Clock
By : donjr Spiegelblatt
Created: 2012-06-18 Edited: 2012-06-18
Worlds: Second Life

the Zip file

Download all files for Clock_Linkable
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Clock_Linkable_1.lsl
1 // Copyright 2009 by Donjr Spiegelblatt
2 //
3 // You are permitted to use, share, and adapt this code under the
4 // terms of the Creative Commons Public License described in full
5 // at http://creativecommons.org/licenses/by/3.0/legalcode.
6 // That means you must keep the credits, do nothing to damage our
7 // reputation, and do not suggest that we endorse you or your work.
8
9 float Offset = 0.0;
10 integer ListenHandle = 0;
11 integer dTimer = 0;
12
13 Dialog(key id)
14 {
15 list ShortMenuForButtons = ["-1", "-0.5", "1", "-3", "done", "3", "-6", "0.5", "6"];
16 llListenRemove(ListenHandle);
17 integer channel = (integer)(llFrand(-1000000000.0) - 1000000000.0); //we generate random channel...
18 ListenHandle = llListen(channel,"", id,""); //...and we start to listen on it
19 dTimer = llGetUnixTime() + 60; // Give the user 60 seconces to respond.
20 llDialog(id, "\nSelect Your time OffSet:\n Curren Offset is " + ((string)Offset), ShortMenuForButtons, channel);
21 }
22
23 integer GetLinkNames(string name)
24 {// return a 'list link numbers' of objects with the name 'name'
25 integer n;
26 integer stop = llGetNumberOfPrims() + 1;
27 for (n=llGetLinkNumber() + 1; n < stop; n++)
28 {
29 // llSay(0, llGetLinkName(n) + " is " + (string)n);
30 if( llGetLinkName(n) == name )
31 return n;
32 }
33 return -1;
34 }
35
36 integer HourHand;
37 integer MinuteHand;
38 integer SecondHand;
39
40 SetHand(integer lnk, float Z)
41 {
42 integer this = llGetLinkNumber();
43 vector rotPoint = llGetPos(); // in global coordinates
44 rotation rot = llEuler2Rot(<0,0.0,DEG_TO_RAD * (Z * -1)>);
45 list parms;
46 if(this > 1)
47 {
48 rot = (rot * llGetLocalRot()) / llGetRootRotation();
49 parms = [PRIM_POSITION, (rotPoint + ((llGetRootPosition() - rotPoint) * rot)) / llGetLocalRot(), PRIM_ROTATION, rot];
50 }
51 else
52 parms = [PRIM_ROTATION, rot / llGetRootRotation()];
53 if( this != lnk )
54 llSetLinkPrimitiveParamsFast(lnk, parms );
55 }
56
57 default
58 {
60 {
61 HourHand = GetLinkNames("HourHand");
62 MinuteHand = GetLinkNames("MinuteHand");
63 SecondHand = GetLinkNames("SecondHand");
64 if( HourHand > 0 && MinuteHand > 0 && SecondHand > 0 )
66 else
67 llSay(0, "ERROR: Object is invalidly configured!!! HourHand=" + ((string)HourHand) + " MinuteHand=" + ((string)MinuteHand) + " SecondHand=" + ((string)SecondHand));
68 }
69 changed(integer change)
70 {
71 if(change & CHANGED_LINK)
72 {
73 HourHand = GetLinkNames("HourHand");
74 MinuteHand = GetLinkNames("MinuteHand");
75 SecondHand = GetLinkNames("SecondHand");
76 if( HourHand > 0 && MinuteHand > 0 && SecondHand > 0 )
78 else
79 {
80 llSay(0, "ERROR: Invalidly configured!!! HourHand=" + ((string)HourHand) + " MinuteHand=" + ((string)MinuteHand) + " SecondHand=" + ((string)SecondHand));
81 llSetTimerEvent(0); // Stop the clock
82 }
83 }
84 }
85 timer()
86 {
87 if( ListenHandle )
88 {
89 if( dTimer < llGetUnixTime() )
90 {
91 // Handle menu timeout
92 llListenRemove(ListenHandle);
93 ListenHandle = 0;
94 }
95 }
96 //llOwnerSay("here");
97 integer t= (integer)(llGetGMTclock() + ( Offset * 3600 ));
98 if((Offset * 3600) + t > 86400)
99 {
100 t -= 86400;
101 }
102 else if((Offset * 3600) + t < 0)
103 {
104 t += 86400;
105 }
106
107 integer hour = (t / 3600) % 12;
108 integer min = (t % 3600) / 60;
109 integer sec = t % 60;
110
111 float adj = ((float)sec);
112 // llSay(0, "sec adj=" + (string)adj);
113 SetHand(SecondHand, ( adj * 6.0) );
114
115 adj /= 60.0;
116 adj += (float)min;
117 // llSay(0, "min adj=" + (string)adj);
118 SetHand(MinuteHand, (adj * 6.0) );
119
120 adj /= 60.0;
121 adj += ((float)hour);
122 SetHand(HourHand, (adj * 30.0));
123 // llSay(0, "hrs adj=" + (string)adj);
124 }
126 {
127 key toucher = llDetectedKey(0);
128 Dialog(toucher);
129 }
130 listen(integer channel, string name, key id, string str)
131 {
132 llListenRemove(ListenHandle);
133 ListenHandle = 0;
134 if( str != "done" )
135 {
136 float par = (float)str;
137 Offset += par;
138 Dialog(id);
139 }
140 }
141 }

Back to the Best Free Tools in Second Life and OpenSim.