andsim

Untitled

Jun 10th, 2011
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1. // 12/01/08 List command doesn't work. Useless anyways hehe!
  2. string _notecard = "stations";
  3.  
  4. integer chatChannel = 77;
  5. string HELP_MSG = "Touch for Station Selection Dialog Menu";
  6.  
  7. list _radioURLs;
  8. list _radioStations;
  9. list theStations;
  10.  
  11. integer _linenum = 0;
  12. integer curStationOffset = 0;
  13. integer stationChunk = 6;
  14. integer curStationEnd = 5;
  15. integer totalStations = 0;
  16. integer dialogActive = 0;
  17. integer curIdx = -1;
  18. string dispStationStr = "";
  19.  
  20. string NEXT_MSG = "Next >>";
  21. string PREV_MSG = "<< Prev";
  22. string LIST_MSG = "List";
  23.  
  24. string CUR_SET = "c";
  25. string ALL_SET = "a";
  26.  
  27. list cmdNextChunk = [">>", "next", "Next"];
  28. list cmdPrevChunk = ["<<", "prev", "Prev"];
  29. list cmdLsCur = ["ls", "list"];
  30. list cmdLsAll = ["la", "listall"];
  31. list cmdSearch = ["s", "search"];
  32.  
  33. string newURL;
  34. string newDesc;
  35.  
  36. //-----------------------
  37.  
  38. reset_radio()
  39. {
  40. llSetText("starting radio ....",<1,0,0>,1.0 );
  41. llListen(77, "", "", "");
  42. curStationOffset = 0;
  43. curStationEnd = 5;
  44. _linenum = 0;
  45. dialogActive = 0;
  46. _radioURLs = [];
  47. _radioStations = [];
  48. totalStations = 0;
  49. curIdx = -1;
  50. dispStationStr = "";
  51. llGetNotecardLine(_notecard, _linenum);
  52. }
  53.  
  54. add_station(string line)
  55. {
  56. list words = llParseString2List(line, [" ", " ", "="], []);
  57. if (llGetListLength(words) < 2)
  58. {
  59. return;
  60. }
  61. string url = llList2String(words, llGetListLength(words) - 1);
  62. string station = "";
  63. integer i;
  64.  
  65. for (i=0; i<llGetListLength(words) - 1; i++)
  66. {
  67. if (llStringLength(station) > 0)
  68. {
  69. station += " ";
  70. }
  71. station += llList2String(words, i);
  72. }
  73.  
  74. _radioURLs += [url];
  75. _radioStations += [station];
  76. }
  77.  
  78.  
  79. curStations()
  80. {
  81. theStations = [PREV_MSG, LIST_MSG, NEXT_MSG];
  82.  
  83. integer i;
  84. dispStationStr = "";
  85.  
  86. for (i = curStationOffset; i <= curStationEnd; i++)
  87. {
  88. if (curIdx == i)
  89. {
  90. dispStationStr += "*";
  91. } else {
  92. dispStationStr += " ";
  93. }
  94. dispStationStr += (string) (i + 1) + ") ";
  95. dispStationStr += llList2String(_radioStations, i);
  96. dispStationStr += "\n";
  97.  
  98. theStations += (string)(i + 1);
  99. }
  100. }
  101.  
  102.  
  103. doNextSet()
  104. {
  105. curStationOffset += stationChunk;
  106. curStationEnd = curStationOffset + (stationChunk - 1);
  107.  
  108. if (curStationOffset >= totalStations)
  109. {
  110. curStationOffset = 0;
  111. curStationEnd = curStationOffset + (stationChunk - 1);
  112. }
  113.  
  114. if (curStationEnd >= totalStations)
  115. {
  116. curStationEnd = totalStations - 1;
  117. }
  118. }
  119.  
  120.  
  121. doPrevSet()
  122. {
  123. if (curStationOffset > 1 && ((curStationOffset - stationChunk) < 1))
  124. {
  125. curStationOffset = 0;
  126. } else {
  127. curStationOffset -= stationChunk;
  128. }
  129.  
  130. curStationEnd = curStationOffset + (stationChunk - 1);
  131.  
  132. if (curStationEnd >= totalStations)
  133. {
  134. curStationEnd = totalStations - 1;
  135. }
  136.  
  137. if (curStationOffset < 0)
  138. {
  139. curStationEnd = totalStations - 1;
  140. curStationOffset = totalStations - (stationChunk - 1);
  141. }
  142. }
  143.  
  144. doListStations(string mode)
  145. {
  146. integer i;
  147. integer startPos;
  148. integer endPos;
  149.  
  150. if (mode == "a")
  151. {
  152. startPos = 0;
  153. endPos = totalStations - 1;
  154. }
  155. else
  156. {
  157. startPos = curStationOffset;
  158. endPos = curStationEnd;
  159. }
  160.  
  161. for (i = startPos; i <= endPos; i++)
  162. {
  163. string newURL = llList2String(_radioURLs, i);
  164. string newDesc = llList2String(_radioStations, i);
  165. llSay(0, (string)(i + 1) + ": " + newDesc + " = " + newURL);
  166. }
  167. }
  168.  
  169.  
  170. doSearch(list theTerms)
  171. {
  172. integer i;
  173. string thePhrase = llToLower(llDumpList2String(theTerms, " "));
  174. llSay(0, "the term is " + thePhrase);
  175.  
  176. for (i = 0; i < totalStations; i++)
  177. {
  178. string curString = llList2String(_radioStations, i);
  179. if (llSubStringIndex(llToLower(curString), thePhrase) != -1)
  180. {
  181. string newURL = llList2String(_radioURLs, i);
  182. llSay(0, (string)(i + 1) + ": " + curString + " = " + newURL);
  183. }
  184. }
  185. }
  186.  
  187. //-----------------------
  188.  
  189. default
  190. {
  191. //on_rez(integer start_param)
  192. //{
  193. //reset_radio();
  194. //}
  195.  
  196. state_entry()
  197. {
  198. llSay(0, "NOTE: If you edit stations notecard...you must reset Radio script at this time");
  199. reset_radio();
  200. }
  201. // For some reason reset radio on changing stations notecard was doubling up menu
  202. // Guess manual script reset for now :)
  203. //changed(integer change)
  204. //{
  205. //if (change & CHANGED_INVENTORY)
  206. //{
  207. //reset_radio();
  208. //}
  209. //}
  210.  
  211. dataserver(key query_id, string data)
  212. {
  213. if (data != EOF)
  214. {
  215. add_station(data);
  216. _linenum++;
  217.  
  218. if (_linenum % 3 == 0)
  219. {
  220. llSetText("starting: \n" + (string)_linenum + " stations ...",
  221. <1,0,0>,1.0 );
  222. }
  223. llGetNotecardLine(_notecard, _linenum);
  224. return;
  225. }
  226. llListen(93, "", NULL_KEY, "");
  227.  
  228. totalStations = llGetListLength(_radioURLs);
  229. llSay(0, HELP_MSG);
  230. dialogActive = 1;
  231. llSetText("", <1,0,0>, 1.0 );
  232. }
  233.  
  234. touch_start(integer touchNumber)
  235. {
  236. curStations();
  237.  
  238. llDialog(llDetectedKey(0),
  239. dispStationStr,
  240. theStations, 93);
  241. }
  242.  
  243. listen(integer channel, string name, key id, string message)
  244. {
  245.  
  246. if (dialogActive == 0)
  247. {
  248. llWhisper(0, " ... still loading stations ...");
  249. return;
  250. }
  251.  
  252. if (message == "")
  253. {
  254. message = "cur";
  255. }
  256.  
  257.  
  258. list words = llParseString2List(message, [" ", " ", "="], []);
  259. list testFind = llList2List(words, 0, 0);
  260.  
  261. if (llListFindList(cmdNextChunk, testFind) != -1)
  262. {
  263. doNextSet();
  264. curStations();
  265. if (channel == chatChannel)
  266. {
  267. doListStations(CUR_SET);
  268. }
  269. else
  270. {
  271. llDialog(id, dispStationStr,theStations, 93);
  272. }
  273. return;
  274. }
  275.  
  276. else if (llListFindList(cmdPrevChunk, testFind) != -1)
  277. {
  278. doPrevSet();
  279. curStations();
  280. if (channel == chatChannel)
  281. {
  282. doListStations(CUR_SET);
  283. }
  284. else
  285. {
  286. llDialog(id, dispStationStr, theStations, 93);
  287. }
  288. return;
  289. }
  290.  
  291. else if (llListFindList(cmdSearch, testFind) != -1)
  292. {
  293. doSearch(llList2List(words, 1, -1));
  294. return;
  295. }
  296.  
  297. else if (llListFindList(cmdLsAll, testFind) != -1)
  298. {
  299. doListStations(ALL_SET);
  300. return;
  301. }
  302.  
  303.  
  304. else if (llListFindList(cmdLsCur, testFind) != -1)
  305. {
  306. doListStations(CUR_SET);
  307. return;
  308. }
  309.  
  310.  
  311. else if ((integer)message > 0 && (integer)message < 256)
  312. {
  313. curIdx = (integer)message - 1;
  314.  
  315. string newURL = llList2String(_radioURLs, curIdx);
  316. string newDesc = llList2String(_radioStations, curIdx);
  317.  
  318. llSay(0, "Setting Station " + message + ": " + newDesc);
  319. //llSay(0, newDesc + " = " + newURL);
  320. llSetParcelMusicURL(newURL);
  321. }
  322. }
  323. }
Advertisement
Add Comment
Please, Sign In to add comment