Jump to content

Stuck Ugggh ... Can Someone please help??


JacobMcKinght
 Share

You are about to reply to a thread that has been inactive for 2555 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am in no way a script guru but am learning quickly and all is starting to make a lil since now after a few weeks of studying up on code and exampples and plug and play and compiling errors lol but I have a problem. I have two scripts and i need one to draw something off another. Now, i know of 2 ways (llSay & llListen, and llLinked message) however i have not dealt with the latter very much. so my problem is this:

Script 1 - Radio Tuner- changes station through menu allows station presets.

Script 2 - Retrieves stream info. (Stream url, song, artist) Manually have to enter in Parcel Music url into script.

The Problem is I need script 2 to to be able to retrieve the url from Script 1 when the stream is changed. I am sure i probably know how to but for whatever reason cant think of how to atm lol has caused me a headache for 2 days and i now am seeking help. i will paste the following scripts below.

Script 1:Radio Tuner

string  _notecard = "URL";

integer chatChannel = 77;


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;
list cmdPrevChunk;
list cmdLsCur;
list cmdLsAll;
list cmdSearch;


//-----------------------

reset_radio() {
    
    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 += "";

        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(list theTerms) {
    integer i;
    string thePhrase = llToLower(llDumpList2String(theTerms, " "));
    llSay(0, "the term is " + thePhrase);

    for (i = 0; i < totalStations; i++) {
        string curString = llList2String(_radioStations, i);
        if (llSubStringIndex(llToLower(curString), thePhrase) != -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();
        cmdNextChunk = [">>", "next", "Next", NEXT_MSG];
        cmdPrevChunk = ["<<", "prev", "Prev", PREV_MSG];
        cmdLsCur     = ["ls", "list", LIST_MSG];
        cmdLsAll     = ["la", "listall"];
        cmdSearch    = ["s", "search"];

    }

    changed(integer change) {
        if (change & CHANGED_INVENTORY) {
            reset_radio();
        }
    }

    dataserver(key query_id, string data) {
        if (data != EOF) {
            add_station(data);
            _linenum++;

            if (_linenum % 3 == 0) {
             llSay(0, "Processing Server Info... Please Wait.");   
llSay(0, "Proccessing Finished... System Library Updated.");
            }
            llGetNotecardLine(_notecard, _linenum);
            return;
        }
        llListen(93, "", NULL_KEY, "");

        totalStations = llGetListLength(_radioURLs);
        dialogActive = 1;
        
    }

    touch_start(integer touchNumber) 
    {
        if(llDetectedLinkNumber(0) != llGetLinkNumber())
            return;
        curStations();
 key toucher = llDetectedKey(0);
    
        if (!llSameGroup(toucher))
        {
            return;
        }
        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(llList2List(words, 1, -1));
            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, "Updating Parcel Info.... Stream Changed to  " + message + ":");
            llSay(0, newDesc + " = " + newURL);
            llSetParcelMusicURL(newURL);
        }
    }
}



 Script 2: Stream Info

string url = "http://uplink.duplexfx.com:8030/";

float checkTime = 15.0;

list messages = [
    "! JTD ! Shoutcast Tip System",  // line 1 is larger -- use for your club name
    "Stream", // small text -- heading for next line
    "~~STREAM_TITLE~~",  // medium text 40 characters
    "Artist", // small text -- heading for next line
    "~~CURRENT_SONG_ARTIST~~", // medium text 40 characters
    "Title", // small text -- heading for next line
    "~~CURRENT_SONG_TITLE~~" // medium text 40 characters
    ];


string say = "Now Playing: ~~CURRENT_SONG_TITLE~~ by ~~CURRENT_SONG_ARTIST";

vector background = <0,.8,.7>;
vector foreground = <1,1,1>;
string fontTexture = "XyzzyText Font Trajan";

//
//
//


// Stream 
integer STREAM_STATUS_URL = 22100;
integer STREAM_STATUS_TIME = 22101;
integer STREAM_STATUS_STOP = 22102;
integer STREAM_STATUS_DATA = 22103;
integer STREAM_STATUS_ERROR = 22104;

// Text
integer DISPLAY_STRING      = 204000; 
integer DISPLAY_EXTENDED    = 204001; 
integer REMAP_INDICES       = 204002; 
integer RESET_INDICES       = 204003; 
integer SET_FADE_OPTIONS    = 204004; 
integer SET_FONT_TEXTURE    = 204005; 
integer SET_LINE_COLOR      = 204006; 
integer SET_COLOR           = 204007; 
integer RESCAN_LINKSET      = 204008;


list statusData;



dumpData()
{
    integer n = llGetListLength(statusData);
    llOwnerSay((string)n);
    string s = "\n";
    while(--n >= 0)
    {
        s += llList2String(statusData,n-1) + "=" + llList2String(statusData,n) + "\n";
        n--;
        if (llStringLength(s) > 512)
        {
            llOwnerSay(s);
            s = "\n";
        }
    }
    llOwnerSay(s);
}

string getItem(string name)
{
    integer i = llListFindList(statusData,[ "=="+llToUpper(name) ]);
    if (i >= 0) return llList2String(statusData,i+1);
    return("");
}

list priorMessages;
string priorSay;

string fixMessage(string s)
{
    list split = llParseStringKeepNulls(s,[ "~~" ],[]);
    integer n = llGetListLength(split);
    string s2;
    while(--n >= 0)
    {
        if (n & 1)
        {
            s2 = getItem(llList2String(split,n)) + s2;
        }
        else
        {
            s2 = llList2String(split,n) + s2;
        }
    }
    return s2;
}


updateMessages()
{
    integer n = llGetListLength(messages);
    integer i;
    for (i = 0; i < n; i++)
    {
        string m = llList2String(priorMessages,i);
        string r = fixMessage(llList2String(messages,i));
        //llOwnerSay((string)i+":"+r);
        if (r != m)
        {
            priorMessages = llListReplaceList(priorMessages,[ r ],i,i);
            llMessageLinked(LINK_THIS,DISPLAY_STRING,r,(string)i);            
            //llOwnerSay((string)i+":"+r);
        }
    }            
    if (say != "")
    {
        string s = fixMessage(say);
        if (s != priorSay)
        {
            llSay(0,s);
            priorSay = s;
        }
    }
}



integer retries = 0;

default
{
    state_entry()
    {
        priorMessages =[];
        priorSay = "";
        llSetColor(background,ALL_SIDES);
        llMessageLinked(LINK_THIS,SET_FONT_TEXTURE,"",(key)fontTexture);
        llMessageLinked(LINK_THIS,SET_COLOR,(string)background,"");
        integer n = llGetListLength(messages);
        while(--n >= 0)
        {
            llMessageLinked(LINK_THIS,SET_LINE_COLOR,(string)foreground,(string)n);
            llMessageLinked(LINK_THIS,DISPLAY_STRING,"",(string)n);
        }
        llMessageLinked(LINK_SET,STREAM_STATUS_TIME,(string)checkTime,NULL_KEY);
         llMessageLinked(LINK_SET,STREAM_STATUS_URL,url,NULL_KEY);
        
    }
    link_message(integer sender, integer num, string message, key id)
    {
        if (num == STREAM_STATUS_DATA)
        {
            retries = 0;
            statusData = llParseStringKeepNulls(message,[ "~||~" ], []);
            //dumpData();  // Uncomment this if you're curious to what status items you have available
            updateMessages();
        }
        if (num == STREAM_STATUS_ERROR)
        {
            retries++;
            if (retries > 2) llSay(0,"ERROR on stream:"+url+":"+message);
            if (retries < 10) llMessageLinked(LINK_SET,STREAM_STATUS_URL,url,NULL_KEY);
            if (retries >= 10) llSay(0,"Stream Status stopped due to errors");
        }
    }
    touch_start(integer num)
    {
        if (llDetectedGroup(0) || llDetectedKey(0) == llGetOwner())
        {
            llSay(0,"Initiating Shut Down Sequence...");
            llSay(0,"System Status OK... Powering Down.");
            state stop;
        }
    }
}

state stop
{
    state_entry()
    {
        llMessageLinked(LINK_SET,STREAM_STATUS_STOP,"",NULL_KEY);
    }
    touch_start(integer num)
    {
        llSay(0,"System Initialized - Powering On.");
        state default;
    }
}

 

Any and all help would be greatly appreciated... 

Thank You :)

Link to comment
Share on other sites

Add a llMessageLinked() to the first script so that when the stream is changed it sends the URL to the second script.

You have an awful lot of llMessageLinked()s in that second script even though it's only talking to itself and not handling most of them.  If I were you I'd start by taking them all out except for STREAM_STATUS_DATA and STREAM STATUS_ERROR (which are the two that are actioned).  Then see if you can understand what the scripts are really doing.

Both of the scripts look long and complex for what you're trying to do.  If you wrote them; well done for doing do much.  If you got them somewhere else and are trying to edit them; simplify!  Start with what you DO know about scripts and build from there, these will just confuse the situation.

  • Like 1
Link to comment
Share on other sites

Thanks for replying peter.. i have moded a little bit but most was written by someone else i found along the way. the 2nd script is one of 3 other scripts but those are for the display board.. my problem is is i need to know how the linked messages look as i do not fully understand with these already prwritten and so complex i have this ready to rock and roll but just need to add that last bit in to sell it to be automatic... if there is anyway you or someone could show me how it should look and where to plug it in i would be greatful

ty

 

Link to comment
Share on other sites

Script 1:
The function that actually sets the music stream is "llSetParcelMusicURL(newURL)", right at the bottom of the first script. You want to send 'newURL' to the other script so you will use the linked-message function llMessageLinked() http://wiki.secondlife.com/wiki/LlMessageLinked.

The first parameter is the prim link-number that the message will be sent to, so you need to set this to wherever the 'script 2' is. The "LINK_*" LSL constants make that a bit easier - if the scripts are in the same prim use LINK_THIS, if they are in different prims but 'script 2' is in the root prim use LINK_ROOT, otherwise use LINK_SET and forget about it.

The 'data' part of llMessageLinked() requires that you send an integer, a string and a key. You can put anything you like in those parameters and use them for whatever you like. Your 'script 2' is using the integer to identify what type of message this is, eg; STREAM_STATUS_DATA. You want 'script 1' to tell 'script 2' that this is the URL and as it's defined in 'script 2' but not used at the moment I suggest you use 22100 for the integer, defined as 'STREAM_STATUS_URL' in 'script 2'. There's no need to define that in 'script 1' as well, you can just use the literal: llMessageLinked(LINK_SET, 22100, ..........).

Pretty obviously you need to send the variable 'newURL', which is a string, and there's no key data that you want to send, so use the LSL constant NULL_KEY. That gives you the complete function, so in 'script 1', after the llSetParcelMusicURL() function, add the line "llMessageLinked(LINK_SET, 22100, newURL, NULL_KEY);"

Script 2:
Script 2 is already handling two types of linked message in the link_message() handler, you just need to add a section that adds a third to 'unwrap' newURL again; if(num == STREAM_STATUS_URL){ url = message; ... }

Once you've got the new URL like that you'll have to decide what to do with it but i think you'll be disappointed.  As far as I can see the script doesn't do anything to retrieve the stream data that you want.

Link to comment
Share on other sites

  • 5 years later...

I see the link on the wiki fine at http://wiki.secondlife.com/wiki/Category:LSL_Functions, and the article says testing on the main release in 2011 had it compiling but with empty output. It doesn't say there are any problems with it, but it's a very specific thingy and only works if the owner owns the parcel, apparently... I'm sure someone will know way more about it than I do, but I'll still try it out later inworld and see if I can get it to compile/work in a script.

Oh, and it does have the little flag that indicates "The LSO function ID for the function is not known, or it may not have one." I have no idea what that means, though... ^-^;

Edited by Berksey
Link to comment
Share on other sites

thanks Berksey, have a feeling it is a recent bug, it won't compile for me at all, and in the example on the wiki it shows in black not red like most lsl commands appear. i thought it worked before, so maybe it's a temp bug

Link to comment
Share on other sites

All I'm seeing so far is that it was scheduled to go and exists as a function with a missing or possibly never-existing ID... I'll have to either find something with it in, or hack together some little whimmydiddle and try it at home and see what it does. Oh, duh, there's a script example on the page...

I'll post results when I get them~!

 

EDIT: I got the sample script to compile. Apparently if I want it to work all the way and return proper results, I'll have to get my SL mom to make a copy of the script and put it into the object, because you have to be the land owner and able to deed the obect or it won't tell you the parcel music URL anyway... But it did compile, and the error it threw was based on it actually working properly, I suppose... at least its safeguard is in place, i.e. "[16:32] Object: Sorry, could not retrieve parcel's music URL. You'll either need to be the land owner or able to deed me."

Now I want to make it work. I'll see if I can get Mom to help me and nope, I ain't even embarrassed to say that~! <-<; I'm a big girl, I just don't own the parcel is all. >->;

Edited by Berksey
updatings, and "object" has a "j" in it.
Link to comment
Share on other sites

9 hours ago, kimmie15 said:

Thanks Innula, i'll play with it some more then, find where im making my mistakes.

Hugs

Glad to help.  

If you can't resolve the problems after you've played with it, I'm sure someone here can help.   If you need more help, though, it might be better to start a new thread rather than add it to this very old one.

Best of luck!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2555 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...