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 AnalogClock  

AnalogClock

AnalogClock

Category: Clock
By : Encog Dod
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for AnalogClock
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. AnalogClock_1.lsl
Get file # 2. AnalogClock_2.lsl
Get file # 3. AnalogClock_3.lsl
1 // From the book:
2 //
3 // Scripting Recipes for Second Life
4 // by Jeff Heaton (Encog Dod in SL)
5 // ISBN: 160439000
6 X// Copyright 2007 by Heaton Research, Inc.
7 //
8 // This script may be freely copied and modified so long as this header
9 // remains unmodified.
10 //
11 // For more information about this book visit the following web site:
12 //
13 // http://www.heatonresearch.com/articles/series/22/
14
15 setClock()
16 {
18 integer hours = t / 3600;
19 integer minutes = (t % 3600) / 60;
20 integer minutes_angle = minutes;
21 integer hours_angle = hours;
22
23 minutes_angle*=6;
24 minutes_angle = 180-minutes_angle;
25
26 hours_angle *= 30;
27 hours_angle+= (minutes/12)*6;
28 hours_angle =180 - hours_angle;
29
30
31 llSetLinkPrimitiveParams(3,[PRIM_TEXTURE, 0, "hour", <1,1,1>, <0,0,0>, hours_angle * DEG_TO_RAD ]);
32 llSetLinkPrimitiveParams(2,[PRIM_TEXTURE, 0, "minute", <1,1,1>, <0,0,0>, minutes_angle * DEG_TO_RAD]);
33 }
34
35 default
36 {
38 {
39
41 setClock();
42
43 }
44
45 timer()
46 {
47 setClock();
48 }
49
50
51 }

AnalogClock

Minute Hand

Category: Clock
By : Encog Dod
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 // Copyright (c) 2008, Scripting Your World
2 // All rights reserved.
3 //
4 // Scripting Your World
5 // By Dana Moore, Michael Thome, and Dr. Karen Zita Haigh
6 // http://syw.fabulo.us
7 // http://www.amazon.com/Scripting-Your-World-Official-Second/dp/0470339837/
8 //
9 // You are permitted to use, share, and adapt this code under the
10 // terms of the Creative Commons Public License described in full
11 // at http://creativecommons.org/licenses/by/3.0/legalcode.
12 // That means you must keep the credits, do nothing to damage our
13 // reputation, and do not suggest that we endorse you or your work.
14
15 // Listing 10.2: Clock Hands
16 integer gCurrentHour;
17 integer gCurrentMin;
18
19 setHandPosition(integer hours, integer minutes) {
20 integer degrees;
21 if(llGetObjectName() == "MinuteHand") {
22 float degreesPerMinute = 360.0 / 60.0;
23 degrees = (integer)(minutes * degreesPerMinute);
24 } else {
25 if(hours>12) hours -= 12;
26 integer degreesPerHour = 360 / 12;
27 float degreesPerMinute = 360.0 / (12.0 * 60.0);
28 degrees = hours * degreesPerHour + (integer)(minutes * degreesPerMinute);
29 }
30 rotation deltaRot = llEuler2Rot( <0,0,-degrees> * DEG_TO_RAD);
31
32 // we know that midnight/noon is 0 degrees around the z axis
33 // so we simply want to add minutes from zero
34 vector currentOffset = ZERO_VECTOR;
35 vector size = llGetScale();
36 currentOffset.x += size.x / 2.0;
37 vector newOffset = currentOffset * deltaRot;
38 llSetLocalRot(deltaRot);
39 llSetPos(newOffset);
40 }
41 default
42 {
43 link_message(integer sender, integer _num, string msg, key id) {
44 llOwnerSay(llGetObjectName()+" received time: "+msg);
45 vector time = (vector)msg;
46 integer gCurrentHour = (integer)time.x;
47 integer gCurrentMin = (integer)time.y;
48 setHandPosition(gCurrentHour, gCurrentMin);
49 }
50 }

AnalogClock

Hour Hand

Category: Clock
By : Encog Dod
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 // Copyright (c) 2008, Scripting Your World
2 // All rights reserved.
3 //
4 // Scripting Your World
5 // By Dana Moore, Michael Thome, and Dr. Karen Zita Haigh
6 // http://syw.fabulo.us
7 // http://www.amazon.com/Scripting-Your-World-Official-Second/dp/0470339837/
8 //
9 // You are permitted to use, share, and adapt this code under the
10 // terms of the Creative Commons Public License described in full
11 // at http://creativecommons.org/licenses/by/3.0/legalcode.
12 // That means you must keep the credits, do nothing to damage our
13 // reputation, and do not suggest that we endorse you or your work.
14
15 // Listing 10.2: Clock Hands
16 integer gCurrentHour;
17 integer gCurrentMin;
18
19 setHandPosition(integer hours, integer minutes) {
20 integer degrees;
21 if(llGetObjectName() == "MinuteHand") {
22 float degreesPerMinute = 360.0 / 60.0;
23 degrees = (integer)(minutes * degreesPerMinute);
24 } else {
25 if(hours>12) hours -= 12;
26 integer degreesPerHour = 360 / 12;
27 float degreesPerMinute = 360.0 / (12.0 * 60.0);
28 degrees = hours * degreesPerHour + (integer)(minutes * degreesPerMinute);
29 }
30 rotation deltaRot = llEuler2Rot( <0,0,-degrees> * DEG_TO_RAD);
31
32 // we know that midnight/noon is 0 degrees around the z axis
33 // so we simply want to add minutes from zero
34 vector currentOffset = ZERO_VECTOR;
35 vector size = llGetScale();
36 currentOffset.x += size.x / 2.0;
37 vector newOffset = currentOffset * deltaRot;
38 llSetLocalRot(deltaRot);
39 llSetPos(newOffset);
40 }
41 default
42 {
43 link_message(integer sender, integer _num, string msg, key id) {
44 llOwnerSay(llGetObjectName()+" received time: "+msg);
45 vector time = (vector)msg;
46 integer gCurrentHour = (integer)time.x;
47 integer gCurrentMin = (integer)time.y;
48 setHandPosition(gCurrentHour, gCurrentMin);
49 }
50 }

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