User:Aamic Zhong: Difference between revisions
Jump to navigation
Jump to search
Aamic Zhong (talk | contribs) |
Aamic Zhong (talk | contribs) |
||
| Line 34: | Line 34: | ||
} | } | ||
---- | ---- | ||
=A Radio Script= | |||
string _notecard = "stations-short"; | |||
integer chatChannel = 77; | |||
string HELP_MSG = "Touch for Stations";// dialog, or use ch 77 to change stations (example \"/77 3\")"; | |||
list _radioURLs; | |||
list _radioStations; | |||
list theStations; | |||
integer _linenum = 0; | |||
integer curStationOffset = 0; | |||
integer stationChunk = 6; | |||
integer curStationEnd = 5; | |||
integer totalStations = 0; | |||
integer dialogActive = 0; | |||
integer curIdx = -1; | |||
string dispStationStr = ""; | |||
string NEXT_MSG = "Next >>"; | |||
string PREV_MSG = "<< Prev"; | |||
string LIST_MSG = "List"; | |||
string CUR_SET = "c"; | |||
string ALL_SET = "a"; | |||
list cmdNextChunk = [">>", "next", "Next", NEXT_MSG]; | |||
list cmdPrevChunk = ["<<", "prev", "Prev", PREV_MSG]; | |||
list cmdLsCur = ["ls", "list", LIST_MSG]; | |||
list cmdLsAll = ["la", "listall"]; | |||
list cmdSearch = ["s", "search"]; | |||
string newURL; | |||
string newDesc; | |||
//----------------------- | |||
reset_radio() { | |||
llSetText("starting radio ....", // message to display | |||
<1,0,0>, // color: <red,green,blue> | |||
1.0 ); // 1.0 = 100% opaque, 0.0 = transparent | |||
llListen(77, "", "", ""); | |||
curStationOffset = 0; | |||
curStationEnd = 5; | |||
_linenum = 0; | |||
dialogActive = 0; | |||
_radioURLs = []; | |||
_radioStations = []; | |||
totalStations = 0; | |||
curIdx = -1; | |||
dispStationStr = ""; | |||
llGetNotecardLine(_notecard, _linenum); | |||
} | |||
add_station(string line) { | |||
list words = llParseString2List(line, [" ", " ", "="], []); | |||
if (llGetListLength(words) < 2) { | |||
return; | |||
} | |||
string url = llList2String(words, llGetListLength(words) - 1); | |||
string station = ""; | |||
integer i; | |||
for (i=0; i<llGetListLength(words) - 1; i++) { | |||
if (llStringLength(station) > 0) { | |||
station += " "; | |||
} | |||
station += llList2String(words, i); | |||
} | |||
_radioURLs += [url]; | |||
_radioStations += [station]; | |||
} | |||
curStations() { | |||
theStations = [PREV_MSG, LIST_MSG, NEXT_MSG]; | |||
integer i; | |||
dispStationStr = ""; | |||
// llWhisper(0, "offset: " + (string)curStationOffset); | |||
// llWhisper(0, "end: " + (string)curStationEnd); | |||
for (i = curStationOffset; i <= curStationEnd; i++) { | |||
if (curIdx == i) { | |||
dispStationStr += "*"; | |||
} else { | |||
dispStationStr += " "; | |||
} | |||
dispStationStr += (string) (i + 1) + ") "; | |||
dispStationStr += llList2String(_radioStations, i); | |||
dispStationStr += "\n"; | |||
theStations += (string)(i + 1); | |||
} | |||
} | |||
doNextSet() { | |||
curStationOffset += stationChunk; | |||
curStationEnd = curStationOffset + (stationChunk - 1); | |||
if (curStationOffset >= totalStations) { | |||
curStationOffset = 0; | |||
curStationEnd = curStationOffset + (stationChunk - 1); | |||
} | |||
if (curStationEnd >= totalStations) { | |||
curStationEnd = totalStations - 1; | |||
} | |||
} | |||
doPrevSet() { | |||
if (curStationOffset > 1 && ((curStationOffset - stationChunk) < 1)) { | |||
curStationOffset = 0; | |||
} else { | |||
curStationOffset -= stationChunk; | |||
} | |||
curStationEnd = curStationOffset + (stationChunk - 1); | |||
if (curStationEnd >= totalStations) { | |||
curStationEnd = totalStations - 1; | |||
} | |||
if (curStationOffset < 0) { | |||
curStationEnd = totalStations - 1; | |||
curStationOffset = totalStations - (stationChunk - 1); | |||
} | |||
} | |||
doListStations(string mode) { | |||
integer i; | |||
integer startPos; | |||
integer endPos; | |||
if (mode == "a") { | |||
startPos = 0; | |||
endPos = totalStations - 1; | |||
} else { | |||
startPos = curStationOffset; | |||
endPos = curStationEnd; | |||
} | |||
for (i = startPos; i <= endPos; i++) { | |||
string newURL = llList2String(_radioURLs, i); | |||
string newDesc = llList2String(_radioStations, i); | |||
llSay(0, (string)(i + 1) + ": " + newDesc + " = " + newURL); | |||
} | |||
} | |||
doSearch(string theTerm) { | |||
integer i; | |||
llSay(0, "the term is " + theTerm); | |||
for (i = 0; i < totalStations; i++) { | |||
string curString = llList2String(_radioStations, i); | |||
if (llSubStringIndex(curString, theTerm) != -1) { | |||
string newURL = llList2String(_radioURLs, i); | |||
llSay(0, (string)(i + 1) + ": " + curString + " = " + newURL); | |||
} | |||
} | |||
} | |||
//----------------------- | |||
default { | |||
on_rez(integer start_param) { | |||
reset_radio(); | |||
} | |||
state_entry() { | |||
reset_radio(); | |||
} | |||
changed(integer change) { | |||
if (change & CHANGED_INVENTORY) { | |||
reset_radio(); | |||
} | |||
} | |||
dataserver(key query_id, string data) { | |||
if (data != EOF) { | |||
add_station(data); | |||
_linenum++; | |||
if (_linenum % 5 == 0) { | |||
llSetText("starting: \n" + (string)_linenum + " stations ...", // message to display | |||
<1,0,0>, // color: <red,green,blue> | |||
1.0 ); // 1.0 = 100% opaque, 0.0 = transparent | |||
} | |||
llGetNotecardLine(_notecard, _linenum); | |||
return; | |||
} | |||
llListen(93, "", NULL_KEY, ""); | |||
totalStations = llGetListLength(_radioURLs); | |||
llSay(0, HELP_MSG); | |||
dialogActive = 1; | |||
llSetText("", <1,0,0>, 1.0 ); | |||
} | |||
touch_start(integer touchNumber) { | |||
curStations(); | |||
llDialog(llDetectedKey(0), | |||
dispStationStr, | |||
theStations, 93); | |||
} | |||
listen(integer channel, string name, key id, string message) { | |||
if (dialogActive == 0) { | |||
llWhisper(0, " ... still loading stations ..."); | |||
return; | |||
} | |||
if (message == "") { | |||
message = "cur"; | |||
} | |||
list words = llParseString2List(message, [" ", " ", "="], []); | |||
list testFind = llList2List(words, 0, 0); | |||
if (llListFindList(cmdNextChunk, testFind) != -1) { | |||
doNextSet(); | |||
curStations(); | |||
if (channel == chatChannel) { | |||
doListStations(CUR_SET); | |||
} else { | |||
llDialog(id, dispStationStr,theStations, 93); | |||
} | |||
return; | |||
} | |||
else if (llListFindList(cmdPrevChunk, testFind) != -1) { | |||
doPrevSet(); | |||
curStations(); | |||
if (channel == chatChannel) { | |||
doListStations(CUR_SET); | |||
} else { | |||
llDialog(id, dispStationStr, theStations, 93); | |||
} | |||
return; | |||
} | |||
else if (llListFindList(cmdSearch, testFind) != -1) { | |||
doSearch(message); | |||
return; | |||
} | |||
else if (llListFindList(cmdLsAll, testFind) != -1) { | |||
doListStations(ALL_SET); | |||
return; | |||
} | |||
else if (llListFindList(cmdLsCur, testFind) != -1) { | |||
doListStations(CUR_SET); | |||
return; | |||
} | |||
else if ((integer)message > 0 && (integer)message < 256) { | |||
curIdx = (integer)message - 1; | |||
string newURL = llList2String(_radioURLs, curIdx); | |||
string newDesc = llList2String(_radioStations, curIdx); | |||
llSay(0, "setting station " + message + ":"); | |||
llSay(0, newDesc + " = " + newURL); | |||
llSetParcelMusicURL(newURL); | |||
} | |||
} | |||
} | |||
*Note card: stations-short | |||
// make a notcard named "stations-short" put in your URL stations. | |||
// Station names like this | |||
// 1FM Dance=http://64.71.145.130:8050 | |||
// NAME = HTTP dont forget the "=" | |||
// In this open radio code you cane make the changes need. This radio code must be kept COPY / MODIFY / RESELL | |||
// | |||
=Radio Stations I Like= | =Radio Stations I Like= | ||
Underwould,http://ct5.fast-serv.com:9970 | Underwould,http://ct5.fast-serv.com:9970 | ||
Revision as of 19:41, 21 April 2008
About Me
I'm from SL with no RL. I’m know as a builder I sale things, buy land and over just have fun. I like to work on new things. Scripting is a learning thing, and one day I hope to really understand it.
Wiki spaces have so much information and most is by the users that pass information on to others users. I have done work on manuals for years. I spent thousand of hours on one book, just to burn it at the end. Its all fun and have learned something each and every time I do something new.
Wiki for the future?
As the information pipeline builds up I think will be over taken by that wiki crave.
My Links
Ez Scripts to learn by
//To set the message /99 Hello World
default{
state_entry()
{
llListen(99, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string message)
{
llSetText(message, <0,1,0>, 1);
}
}
A Radio Script
string _notecard = "stations-short";
integer chatChannel = 77;
string HELP_MSG = "Touch for Stations";// dialog, or use ch 77 to change stations (example \"/77 3\")";
list _radioURLs;
list _radioStations;
list theStations;
integer _linenum = 0;
integer curStationOffset = 0;
integer stationChunk = 6;
integer curStationEnd = 5;
integer totalStations = 0;
integer dialogActive = 0;
integer curIdx = -1;
string dispStationStr = "";
string NEXT_MSG = "Next >>";
string PREV_MSG = "<< Prev";
string LIST_MSG = "List";
string CUR_SET = "c";
string ALL_SET = "a";
list cmdNextChunk = [">>", "next", "Next", NEXT_MSG];
list cmdPrevChunk = ["<<", "prev", "Prev", PREV_MSG];
list cmdLsCur = ["ls", "list", LIST_MSG];
list cmdLsAll = ["la", "listall"];
list cmdSearch = ["s", "search"];
string newURL;
string newDesc;
//-----------------------
reset_radio() {
llSetText("starting radio ....", // message to display
<1,0,0>, // color: <red,green,blue>
1.0 ); // 1.0 = 100% opaque, 0.0 = transparent
llListen(77, "", "", "");
curStationOffset = 0;
curStationEnd = 5;
_linenum = 0;
dialogActive = 0;
_radioURLs = [];
_radioStations = [];
totalStations = 0;
curIdx = -1;
dispStationStr = "";
llGetNotecardLine(_notecard, _linenum);
}
add_station(string line) {
list words = llParseString2List(line, [" ", " ", "="], []);
if (llGetListLength(words) < 2) {
return;
}
string url = llList2String(words, llGetListLength(words) - 1);
string station = "";
integer i;
for (i=0; i<llGetListLength(words) - 1; i++) {
if (llStringLength(station) > 0) {
station += " ";
}
station += llList2String(words, i);
}
_radioURLs += [url];
_radioStations += [station];
}
curStations() {
theStations = [PREV_MSG, LIST_MSG, NEXT_MSG];
integer i;
dispStationStr = "";
// llWhisper(0, "offset: " + (string)curStationOffset);
// llWhisper(0, "end: " + (string)curStationEnd);
for (i = curStationOffset; i <= curStationEnd; i++) {
if (curIdx == i) {
dispStationStr += "*";
} else {
dispStationStr += " ";
}
dispStationStr += (string) (i + 1) + ") ";
dispStationStr += llList2String(_radioStations, i);
dispStationStr += "\n";
theStations += (string)(i + 1);
}
}
doNextSet() {
curStationOffset += stationChunk;
curStationEnd = curStationOffset + (stationChunk - 1);
if (curStationOffset >= totalStations) {
curStationOffset = 0;
curStationEnd = curStationOffset + (stationChunk - 1);
}
if (curStationEnd >= totalStations) {
curStationEnd = totalStations - 1;
}
}
doPrevSet() {
if (curStationOffset > 1 && ((curStationOffset - stationChunk) < 1)) {
curStationOffset = 0;
} else {
curStationOffset -= stationChunk;
}
curStationEnd = curStationOffset + (stationChunk - 1);
if (curStationEnd >= totalStations) {
curStationEnd = totalStations - 1;
}
if (curStationOffset < 0) {
curStationEnd = totalStations - 1;
curStationOffset = totalStations - (stationChunk - 1);
}
}
doListStations(string mode) {
integer i;
integer startPos;
integer endPos;
if (mode == "a") {
startPos = 0;
endPos = totalStations - 1;
} else {
startPos = curStationOffset;
endPos = curStationEnd;
}
for (i = startPos; i <= endPos; i++) {
string newURL = llList2String(_radioURLs, i);
string newDesc = llList2String(_radioStations, i);
llSay(0, (string)(i + 1) + ": " + newDesc + " = " + newURL);
}
}
doSearch(string theTerm) {
integer i;
llSay(0, "the term is " + theTerm);
for (i = 0; i < totalStations; i++) {
string curString = llList2String(_radioStations, i);
if (llSubStringIndex(curString, theTerm) != -1) {
string newURL = llList2String(_radioURLs, i);
llSay(0, (string)(i + 1) + ": " + curString + " = " + newURL);
}
}
}
//-----------------------
default {
on_rez(integer start_param) {
reset_radio();
}
state_entry() {
reset_radio();
}
changed(integer change) {
if (change & CHANGED_INVENTORY) {
reset_radio();
}
}
dataserver(key query_id, string data) {
if (data != EOF) {
add_station(data);
_linenum++;
if (_linenum % 5 == 0) {
llSetText("starting: \n" + (string)_linenum + " stations ...", // message to display
<1,0,0>, // color: <red,green,blue>
1.0 ); // 1.0 = 100% opaque, 0.0 = transparent
}
llGetNotecardLine(_notecard, _linenum);
return;
}
llListen(93, "", NULL_KEY, "");
totalStations = llGetListLength(_radioURLs);
llSay(0, HELP_MSG);
dialogActive = 1;
llSetText("", <1,0,0>, 1.0 );
}
touch_start(integer touchNumber) {
curStations();
llDialog(llDetectedKey(0),
dispStationStr,
theStations, 93);
}
listen(integer channel, string name, key id, string message) {
if (dialogActive == 0) {
llWhisper(0, " ... still loading stations ...");
return;
}
if (message == "") {
message = "cur";
}
list words = llParseString2List(message, [" ", " ", "="], []);
list testFind = llList2List(words, 0, 0);
if (llListFindList(cmdNextChunk, testFind) != -1) {
doNextSet();
curStations();
if (channel == chatChannel) {
doListStations(CUR_SET);
} else {
llDialog(id, dispStationStr,theStations, 93);
}
return;
}
else if (llListFindList(cmdPrevChunk, testFind) != -1) {
doPrevSet();
curStations();
if (channel == chatChannel) {
doListStations(CUR_SET);
} else {
llDialog(id, dispStationStr, theStations, 93);
}
return;
}
else if (llListFindList(cmdSearch, testFind) != -1) {
doSearch(message);
return;
}
else if (llListFindList(cmdLsAll, testFind) != -1) {
doListStations(ALL_SET);
return;
}
else if (llListFindList(cmdLsCur, testFind) != -1) {
doListStations(CUR_SET);
return;
}
else if ((integer)message > 0 && (integer)message < 256) {
curIdx = (integer)message - 1;
string newURL = llList2String(_radioURLs, curIdx);
string newDesc = llList2String(_radioStations, curIdx);
llSay(0, "setting station " + message + ":");
llSay(0, newDesc + " = " + newURL);
llSetParcelMusicURL(newURL);
}
}
}
- Note card: stations-short
// make a notcard named "stations-short" put in your URL stations. // Station names like this // 1FM Dance=http://64.71.145.130:8050 // NAME = HTTP dont forget the "=" // In this open radio code you cane make the changes need. This radio code must be kept COPY / MODIFY / RESELL
//
Radio Stations I Like
Underwould,http://ct5.fast-serv.com:9970 DJDeno,http://88.84.155.153:3500 .977 - 80s,http://205.188.215.229:8004 1-FM,http://64.71.145.130:8070 SKY FM,http://207.200.96.230:8002 1.FM Dance,http://64.71.145.130:8050 SL,http://www.secondjam.com:8000/
- Other known stations
??,http://194.158.114.67:8000 Magic Radio - 80s,http://194.117.194.66:8100 Top40,http://www.getnetradio.com/top40high.asx XRM Radio,http://212.72.165.25:9248 Radio Wazee,http://72.35.226.50:8206 Radio Nigel,http://209.126.212.130:8040 Kink FM,http://81.173.3.20:80 Sky FM,http://160.79.128.30:7712 The Edge,http://67.43.161.248:6001 80s Channel,http://216.218.252.67:8095 idobi Radio,http://213.251.129.50:8080 WDDT Radio,http://205.188.215.226:8018 XRM Radio,http://64.62.253.225:8174 NetClassix,http://67.43.161.248:86 Hit Music Station,http://195.14.0.192:8192 1FM-Jamz,http://64.71.145.130:8055 Todays Best Music,http://68.225.38.47:8000 Urban Radio,http://68.178.250.130:11600 Hot 108 Jamz,http://64.236.34.4:80/stream/1071 The Edge,http://85.17.17.12:8040 Elecktracks,http://64.202.98.132:6390 Chronixmetal,http://205.188.215.225:8022 FM Country,http://216.218.159.151:8020 Boot Liquor Radio,http://207.210.90.66:7880