Home |
Add a script
|
||
|---|---|---|---|
| Category: | Contributor: | Description | |
| Clock | Ariane Brodie | Clock Radio | |
clock-radio-motion detector device.
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.
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
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 23 { 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 } 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. 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 default100 {101 state_entry()102 {104 llSetTouchText("Radio On");106 }107 109 {110 llSetParcelMusicURL(radioURL);111 state radio_on; 112 } 113 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++) { 121 if(llDetectedKey(i) != llGetOwner()){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 132 {133 if (message == "hide"){134 llSetPrimitiveParams([135 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);136 }137 if (message == "show"){138 llSetPrimitiveParams([139 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);140 }141 }142 }143 144 state radio_on145 {146 state_entry()147 {149 llSetTouchText("Rock");151 }152 154 {155 llSetParcelMusicURL("http://vruk.sc.llnwd.net:12265");156 state radio_on1; 157 } 158 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++) { 166 if(llDetectedKey(i) != llGetOwner()){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 177 {178 if (message == "hide"){179 llSetPrimitiveParams([180 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);181 }182 if (message == "show"){183 llSetPrimitiveParams([184 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);185 }186 }187 }188 189 state radio_on1190 {191 state_entry()192 {194 llSetTouchText("80s");196 }197 199 {200 llSetParcelMusicURL("http://64.236.34.67:80/stream/1040");201 state radio_on2; 202 } 203 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++) { 211 if(llDetectedKey(i) != llGetOwner()){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 222 {223 if (message == "hide"){224 llSetPrimitiveParams([225 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);226 }227 if (message == "show"){228 llSetPrimitiveParams([229 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);230 }231 }232 }233 234 state radio_on2235 {236 state_entry()237 {239 llSetTouchText("Jazz");241 }242 244 {245 llSetParcelMusicURL("http://64.236.34.196:80/stream/1019");246 state radio_on3; 247 } 248 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++) { 256 if(llDetectedKey(i) != llGetOwner()){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 267 {268 if (message == "hide"){269 llSetPrimitiveParams([270 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);271 }272 if (message == "show"){273 llSetPrimitiveParams([274 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);275 }276 }277 }278 279 state radio_on3280 {281 state_entry()282 {284 llSetTouchText("Radio Off");286 }287 289 {290 llSetParcelMusicURL("");291 llResetScript(); 292 } 293 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++) { 301 if(llDetectedKey(i) != llGetOwner()){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 312 {313 if (message == "hide"){314 llSetPrimitiveParams([315 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 0.0]);316 }317 if (message == "show"){318 llSetPrimitiveParams([319 PRIM_COLOR, ALL_SIDES, <0.5, 0, 0>, 1.0]);320 }321 }322 }