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
Radio Radio_script  

Radio_script

Radio_script

Category: Radio
By : Angel
Created: 2010-03-04 Edited: 2010-03-04
Worlds: Second Life

the Zip file

Download all files for Radio_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Radio_script_1.lsl
1 string _notecard = "stations";
2
3 integer chatChannel = 77;
4 string HELP_MSG = "touch for station dialog, or use ch 77 to change stations (example '/77')";
5
6 list _radioURLs;
7 list _radioStations;
8 list theStations;
9
10 integer _linenum = 0;
11 integer curStationOffset = 0;
12 integer stationChunk = 6;
13 integer curStationEnd = 5;
14 integer totalStations = 0;
15 integer dialogActive = 0;
16 integer curIdx = -1;
17 string dispStationStr = "";
18
19 string NEXT_MSG = "Next >>";
20 string PREV_MSG = "<< Prev";
21 string LIST_MSG = "List";
22
23 string CUR_SET = "c";
24 string ALL_SET = "a";
25 list cmdNextChunk;
26 list cmdPrevChunk;
27 list cmdLsCur;
28 list cmdLsAll;
29 list cmdSearch;
30
31
32 //-----------------------
33
34 reset_radio() {
35 llSetText("starting radio ....", // message to display
36 <1,0,0>, // color: <red,green,blue>
37 1.0 ); // 1.0 = 100% opaque, 0.0 = transparent
38 llListen(77, "", "", "");
39 curStationOffset = 0;
40 curStationEnd = 5;
41 _linenum = 0;
42 dialogActive = 0;
43 _radioURLs = [];
44 _radioStations = [];
45 totalStations = 0;
46 curIdx = -1;
47 dispStationStr = "";
48 llGetNotecardLine(_notecard, _linenum);
49 }
50
51 add_station(string line) {
52 list words = llParseString2List(line, [" ", " ", "="], []);
53 if(llGetListLength(words) < 2) {
54 return;
55 }
56 string url = llList2String(words, llGetListLength(words) - 1);
57 string station = "";
58 integer i;
59
60 for (i=0; i<llGetListLength(words) - 1; i++) {
61 if(llStringLength(station) > 0) {
62 station += " ";
63 }
64 station += llList2String(words, i);
65 }
66
67 _radioURLs += [url];
68 _radioStations += [station];
69 }
70
71
72 curStations() {
73 theStations = [PREV_MSG, LIST_MSG, NEXT_MSG];
74
75 integer i;
76 dispStationStr = "";
77
78 // llWhisper(0, "offset: " + (string)curStationOffset);
79 // llWhisper(0, "end: " + (string)curStationEnd);
80
81 for (i = curStationOffset; i <= curStationEnd; i++) {
82 if(curIdx == i) {
83 dispStationStr += "*";
84 } else {
85 dispStationStr += " ";
86 }
87 dispStationStr += (string) (i + 1) + ") ";
88 dispStationStr += llList2String(_radioStations, i);
89 dispStationStr += "n";
90
91 theStations += (string)(i + 1);
92 }
93 }
94
95
96 doNextSet() {
97 curStationOffset += stationChunk;
98 curStationEnd = curStationOffset + (stationChunk - 1);
99
100 if(curStationOffset >= totalStations) {
101 curStationOffset = 0;
102 curStationEnd = curStationOffset + (stationChunk - 1);
103 }
104
105 if(curStationEnd >= totalStations) {
106 curStationEnd = totalStations - 1;
107 }
108 }
109
110
111 doPrevSet() {
112 if(curStationOffset > 1 && ((curStationOffset - stationChunk) < 1)) {
113 curStationOffset = 0;
114 } else {
115 curStationOffset -= stationChunk;
116 }
117
118 curStationEnd = curStationOffset + (stationChunk - 1);
119
120 if(curStationEnd >= totalStations) {
121 curStationEnd = totalStations - 1;
122 }
123
124 if(curStationOffset < 0) {
125 curStationEnd = totalStations - 1;
126 curStationOffset = totalStations - (stationChunk - 1);
127 }
128 }
129
130 doListStations(string mode) {
131 integer i;
132 integer startPos;
133 integer endPos;
134
135 if(mode == "a") {
136 startPos = 0;
137 endPos = totalStations - 1;
138 } else {
139 startPos = curStationOffset;
140 endPos = curStationEnd;
141 }
142
143 for (i = startPos; i <= endPos; i++) {
144 string newURL = llList2String(_radioURLs, i);
145 string newDesc = llList2String(_radioStations, i);
146 llSay(0, (string)(i + 1) + ": " + newDesc + " = " + newURL);
147 }
148 }
149
150
151 doSearch(list theTerms) {
152 integer i;
153 string thePhrase = llToLower(llDumpList2String(theTerms, " "));
154 llSay(0, "the term is " + thePhrase);
155
156 for (i = 0; i < totalStations; i++) {
157 string curString = llList2String(_radioStations, i);
158 if(llSubStringIndex(llToLower(curString), thePhrase) != -1) {
159 string newURL = llList2String(_radioURLs, i);
160 llSay(0, (string)(i + 1) + ": " + curString + " = " + newURL);
161 }
162 }
163 }
164
165 //-----------------------
166
167 default {
168 on_rez(integer start_param) {
169 reset_radio();
170 }
171
172 state_entry() {
173 reset_radio();
174 cmdNextChunk = [">>", "next", "Next", NEXT_MSG];
175 cmdPrevChunk = ["<<", "prev", "Prev", PREV_MSG];
176 cmdLsCur = ["ls", "list", LIST_MSG];
177 cmdLsAll = ["la", "listall"];
178 cmdSearch = ["s", "search"];
179
180 }
181
182 changed(integer change) {
183 if(change & CHANGED_INVENTORY) {
184 reset_radio();
185 }
186 }
187
188 dataserver(key query_id, string data) {
189 if(data != EOF) {
190 add_station(data);
191 _linenum++;
192
193 if(_linenum % 3 == 0) {
194 llSetText("starting: n" + (string)_linenum + " stations ...", // message to display
195 <1,0,0>, // color: <red,green,blue>
196 1.0 ); // 1.0 = 100% opaque, 0.0 = transparent
197 }
198 llGetNotecardLine(_notecard, _linenum);
199 return;
200 }
201 llListen(93, "", NULL_KEY, "");
202
203 totalStations = llGetListLength(_radioURLs);
204 llSay(0, HELP_MSG);
205 dialogActive = 1;
206 llSetText("", <1,0,0>, 1.0 );
207 }
208
209 touch_start(integer touchNumber) {
210 curStations();
211
213 dispStationStr,
214 theStations, 93);
215 }
216
217 listen(integer channel, string name, key id, string message) {
218
219 if(dialogActive == 0) {
220 llWhisper(0, " ... still loading stations ...");
221 return;
222 }
223
224 if(message == "") {
225 message = "cur";
226 }
227
228
229 list words = llParseString2List(message, [" ", " ", "="], []);
230 list testFind = llList2List(words, 0, 0);
231
232 if(llListFindList(cmdNextChunk, testFind) != -1) {
233 doNextSet();
234 curStations();
235 if(channel == chatChannel) {
236 doListStations(CUR_SET);
237 } else {
238 llDialog(id, dispStationStr,theStations, 93);
239 }
240 return;
241 }
242
243 else if(llListFindList(cmdPrevChunk, testFind) != -1) {
244 doPrevSet();
245 curStations();
246 if(channel == chatChannel) {
247 doListStations(CUR_SET);
248 } else {
249 llDialog(id, dispStationStr, theStations, 93);
250 }
251 return;
252 }
253
254 else if(llListFindList(cmdSearch, testFind) != -1) {
255 doSearch(llList2List(words, 1, -1));
256 return;
257 }
258
259 else if(llListFindList(cmdLsAll, testFind) != -1) {
260 doListStations(ALL_SET);
261 return;
262 }
263
264
265 else if(llListFindList(cmdLsCur, testFind) != -1) {
266 doListStations(CUR_SET);
267 return;
268 }
269
270
271 else if((integer)message > 0 && (integer)message < 256) {
272 curIdx = (integer)message - 1;
273
274 string newURL = llList2String(_radioURLs, curIdx);
275 string newDesc = llList2String(_radioStations, curIdx);
276
277 llSay(0, "setting station " + message + ":");
278 llSay(0, newDesc + " = " + newURL);
279 llSetParcelMusicURL(newURL);
280 }
281 }
282 }

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