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_Radio  

Clock_Radio

found a routine in Wiki to make a digital clock, so I turned it into a clock-radio-motion detector device. It is a simple script that left alone displays the time in any time zone you want, or you can click it to toggle on and off your radio. Or the third function is that of a motion detector that IMs you if someone is near the detector. Update: script now cycles through 4 different channels, and also displays your server time and how long till the next sunrise/sunset.

Category: Clock
By : Ariane Brodie
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Clock_Radio
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Clock_Radio_1.lsl
1 string oldSee = "";
2 // http://64.236.34.67:80/stream/1040 - Club 977 the 80's channel
3 // http://216.218.254.98:8310 - Twister Radio SL Radio
4 // http://vruk.sc.llnwd.net:12265 - Virgin Radio- classic rock
5 // http://64.236.34.196:80/stream/1005 - Smooth Jazz
6 // http://195.140.143.76:8000 - Frequency 3 (French pop)
7 // http://69.28.128.148:80/stream/vruk_vr_hi - Virgin Radio ( UK )
8 // http://64.236.34.67:80/stream/1038 - Hitz Radio - Pop Music
9 // http://64.236.34.196:80/stream/1006 - Mostly Classical
10 // http://64.236.34.196:80/stream/1018 - Nicely Chilled
11 // http://64.236.34.196:80/stream/1011 - Todays Dance Music
12 // http://hifi.kcsm.org:8002 - Jazz - KCSM
13 // http://66.230.159.66:8765 - Hip Hop
14 // http://64.236.34.196:80/stream/1003 - Trance
15 // http://64.202.98.51:7150 - NewAge
16 // http://64.236.34.97:80/stream/2004 - NewAge / Chill
17 // http://64.236.34.97:80/stream/1048 - Radio Paradise
18 string radioURL = "http://64.236.34.97:80/stream/1048";
19 float tz = -7;
20 integer mil = 0;
21
22 string clock(float timezone, integer military)
23 {
24 integer raw = (integer)(llGetGMTclock() + (timezone * 3600));
25 integer shiftraw = raw;
26 if((timezone * 3600) + raw > 86400)
27 {
28 shiftraw = raw - 86400;
29 }
30 else if((timezone * 3600) + raw < 0)
31 {
32 shiftraw = raw + 86400;
33 }
34 integer hours = shiftraw / 3600;
35 integer minutes = (shiftraw % 3600) / 60;
36 integer seconds = shiftraw % 60;
37 string ampm;
38 //non-military time adjustments
39 if(!military)
40 {
41 if(shiftraw < 43200)
42 {
43 ampm = " AM";
44 }
45 else
46 {
47 ampm = " PM";
48 hours -= 12;
49 }
50 }
51 string shours = (string)hours;
52 string sminutes = (string)minutes;
53 string sseconds = (string)seconds;
54
55 //add zeros to single digit minutes/seconds
56 if(llStringLength(sminutes) == 1)
57 {
58 sminutes = "0" + sminutes;
59 }
60 if(llStringLength(sseconds) == 1)
61 {
62 sseconds = "0" + sseconds;
63 }
64 string time = shours + ":" + sminutes + ":" + sseconds + ampm + "(PST)";
65 //the following will time stamp the data sent using SL time.
66 raw = (integer)llGetTimeOfDay();
67 minutes = raw/60;
68 integer mintill;
69 string suntime = "";
70 if(minutes < 30) {
71 mintill = 30 - minutes;
72 suntime = (string)mintill + " min till Sunrise";
73 }
74 if(minutes == 30)
75 suntime = "Sunrise";
76 if(minutes > 30) {
77 mintill = 210 - minutes;
78 suntime = (string)mintill + " min till Sunset";
79 }
80 if(minutes == 210)
81 suntime = "Sunset";
82 if(minutes > 210){
83 mintill = 270 - minutes;
84 suntime = (string)mintill + " min till Sunrise";
85 }
86 shours = "0"+(string)((raw/3600)%4);
87 integer len = llStringLength(shours);
88 shours = llGetSubString(shours, len - 2, len - 1);
89 sminutes = "0"+(string)((raw%3600)/60);
90 len = llStringLength(sminutes);
91 sminutes = llGetSubString(sminutes, len - 2, len - 1);
92 sseconds = "0"+(string)(raw%60);
93 len = llStringLength(sseconds);
94 sseconds = llGetSubString(sseconds, len - 2, len - 1);
95 time = time+"\n"+shours + ":" + sminutes + ":" + sseconds + "(SLT)\n" + suntime;
96 return time;
97 }
98
99 default
100 {
102 {
103 llSensorRepeat("","",AGENT,5,PI,1);
104 llSetTouchText("Radio On");
105 llListen( 5, "", NULL_KEY, "" );
106 }
107
109 {
110 llSetParcelMusicURL(radioURL);
111 state radio_on;
112 }
113
114 sensor(integer n)
115 {
116 integer i;
117 string currenttime = clock(tz,mil);
118 llSetText(currenttime, <1, 1, 1>, 1.0);
119 string iSee = "";
120 for(i=0; i<n; i++) {
122 iSee += llDetectedName(i);
123 }
124 }
125 if(iSee != "" && iSee != oldSee) {
126 llInstantMessage(llGetOwner(), iSee + " is in your lab.");
127 oldSee = iSee;
128 }
129 }
130
131 listen(integer channel, string name, key id, string message)
132 {
133 if(message == "hide"){
135 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);
136 }
137 if(message == "show"){
139 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);
140 }
141 }
142 }
143
144 state radio_on
145 {
147 {
148 llSensorRepeat("","",AGENT,5,PI,1);
149 llSetTouchText("Rock");
150 llListen( 5, "", NULL_KEY, "" );
151 }
152
154 {
155 llSetParcelMusicURL("http://vruk.sc.llnwd.net:12265");
156 state radio_on1;
157 }
158
159 sensor(integer n)
160 {
161 integer i;
162 string currenttime = clock(tz,mil);
163 llSetText(currenttime, <1, 1, 1>, 1.0);
164 string iSee = "";
165 for(i=0; i<n; i++) {
167 iSee += llDetectedName(i);
168 }
169 }
170 if(iSee != "" && iSee != oldSee) {
171 llInstantMessage(llGetOwner(), iSee + " is in your lab.");
172 oldSee = iSee;
173 }
174 }
175
176 listen(integer channel, string name, key id, string message)
177 {
178 if(message == "hide"){
180 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);
181 }
182 if(message == "show"){
184 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);
185 }
186 }
187 }
188
189 state radio_on1
190 {
192 {
193 llSensorRepeat("","",AGENT,5,PI,1);
194 llSetTouchText("80s");
195 llListen( 5, "", NULL_KEY, "" );
196 }
197
199 {
200 llSetParcelMusicURL("http://64.236.34.67:80/stream/1040");
201 state radio_on2;
202 }
203
204 sensor(integer n)
205 {
206 integer i;
207 string currenttime = clock(tz,mil);
208 llSetText(currenttime, <1, 1, 1>, 1.0);
209 string iSee = "";
210 for(i=0; i<n; i++) {
212 iSee += llDetectedName(i);
213 }
214 }
215 if(iSee != "" && iSee != oldSee) {
216 llInstantMessage(llGetOwner(), iSee + " is in your lab.");
217 oldSee = iSee;
218 }
219 }
220
221 listen(integer channel, string name, key id, string message)
222 {
223 if(message == "hide"){
225 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);
226 }
227 if(message == "show"){
229 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);
230 }
231 }
232 }
233
234 state radio_on2
235 {
237 {
238 llSensorRepeat("","",AGENT,5,PI,1);
239 llSetTouchText("Jazz");
240 llListen( 5, "", NULL_KEY, "" );
241 }
242
244 {
245 llSetParcelMusicURL("http://64.236.34.196:80/stream/1019");
246 state radio_on3;
247 }
248
249 sensor(integer n)
250 {
251 integer i;
252 string currenttime = clock(tz,mil);
253 llSetText(currenttime, <1, 1, 1>, 1.0);
254 string iSee = "";
255 for(i=0; i<n; i++) {
257 iSee += llDetectedName(i);
258 }
259 }
260 if(iSee != "" && iSee != oldSee) {
261 llInstantMessage(llGetOwner(), iSee + " is in your lab.");
262 oldSee = iSee;
263 }
264 }
265
266 listen(integer channel, string name, key id, string message)
267 {
268 if(message == "hide"){
270 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);
271 }
272 if(message == "show"){
274 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);
275 }
276 }
277 }
278
279 state radio_on3
280 {
282 {
283 llSensorRepeat("","",AGENT,5,PI,1);
284 llSetTouchText("Radio Off");
285 llListen( 5, "", NULL_KEY, "" );
286 }
287
289 {
292 }
293
294 sensor(integer n)
295 {
296 integer i;
297 string currenttime = clock(tz,mil);
298 llSetText(currenttime, <1, 1, 1>, 1.0);
299 string iSee = "";
300 for(i=0; i<n; i++) {
302 iSee += llDetectedName(i);
303 }
304 }
305 if(iSee != "" && iSee != oldSee) {
306 llInstantMessage(llGetOwner(), iSee + " is in your lab.");
307 oldSee = iSee;
308 }
309 }
310
311 listen(integer channel, string name, key id, string message)
312 {
313 if(message == "hide"){
315 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);
316 }
317 if(message == "show"){
319 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);
320 }
321 }
322 }

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