Jump to content
You are about to reply to a thread that has been inactive for 1401 days.

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

Recommended Posts

To answer the question directly, you need to parse the contents of body down to the parts you want. You may need a bigger HTTP_BODY_MAXLENGTH.

To actually do that, you should first inspect what the exact response is. (Manually, so you know what to expect.) From there, you need llGetSubString and llSubStringIndex to find what exactly to use from the response.

Edited by Wulfie Reanimator
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Wulfie Reanimator said:

To answer the question directly, you need to parse the contents of body down to the parts you want. You may need a bigger HTTP_BODY_MAXLENGTH.

To actually do that, you should first inspect what the exact response is. (Manually, so you know what to expect.) From there, you need llGetSubString and llSubStringIndex to find what exactly to use from the response.

 

2 hours ago, Nova Convair said:

What do you use to display a web-url? A Browser. llSetText is no browser.

Shared media is a browser and Rolig already posted a link about that.

You probably want to look at this, maybe you find something for you:

http://wiki.secondlife.com/wiki/World_API

Hi guys thanks for the reply what I want to do is create a prim that I can put a grid status info into via a script and it shows up as a digital clock and it gives me information with the grid status every hour is there a type of script that I need to do this i may need help with creating the script hopeless at a script making

Link to comment
Share on other sites

I think you may be imagining something very different from what you described in your OP.  Grid Status is a report created by Linden Lab and displayed at the URL I provided above.  If you want to display that web page on the face of a prim, use Shared Media. I also gave you a link to the Knowledge Base article that tells you how to do that.  You don't need any special LSL script at all. 

I have no idea why you are trying to extract information from the Grid Status Report and put it into hover text, but I am beginning to suspect that you are not really asking about Grid Status at all.  Perhaps you simply want to know whether a specific region is on line at the moment?  If so, you can use llRequestSimulatorData.  There's a very simple example at http://wiki.secondlife.com/wiki/LlRequestSimulatorData#Examples that you can modify to look for DATA_SIM_STATUS instead of DATA_SIM_RATING.  Just request the information with a timer-triggered call to the function and display the output in hover text if that's what you are after.

Link to comment
Share on other sites

If by "grid status" you understand users online and for example last report posted on https://status.secondlifegrid.net/ then this thingy may help you to get started with your "digital clock" project. That is also a crude example of parsing contents of the response body @Wulfie Reanimator was talking about few messages above.

 

key gHttpRequestId1;
key gHttpRequestId2;
string gBuildText;

checkData()
{
    gBuildText = "";
    gHttpRequestId1 = llHTTPRequest("http://secondlife.com/xmlhttp/secondlife.php", [HTTP_BODY_MAXLENGTH, 4096], "");
}

string cutString(string theData, string theTag)
{
    integer cutStart = llSubStringIndex(theData, "<" + theTag + ">") + llStringLength("<" + theTag + ">");
    integer cutEnd = llSubStringIndex(theData, "</" + theTag + ">") - 1;
    return llGetSubString(theData, cutStart, cutEnd);
}

default
{

    state_entry ()
    {
        llSetTimerEvent(3600);
        checkData();
    }

    on_rez(integer sp)
    {
        llResetScript();
    }

    timer()
    {
        checkData();
    }

    touch_start(integer sp)
    {
        key targetAvatar = llDetectedKey(0);
        if (llGetAgentSize(targetAvatar) != ZERO_VECTOR)
        {
            llRegionSayTo(targetAvatar, 0, gBuildText);
        }
        else
        {
            llInstantMessage(targetAvatar, gBuildText);
        }
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == gHttpRequestId1)
        {
            gBuildText += "Updated: " + llGetTimestamp();
            if (status == 200 && llSubStringIndex(body, "<status>") != -1)
            {
                gBuildText += "\nGrid: " + cutString(body, "status");
                gBuildText += " | Inworld: " + cutString(body, "inworld");
                gBuildText += "\nSignups: " + cutString(body, "signups");
                gBuildText += " | Logged in past 60 days: " + cutString(body, "logged_in_last_60");
            }
            gHttpRequestId2 = llHTTPRequest("http://status.secondlifegrid.net/history.rss", [HTTP_BODY_MAXLENGTH, 4096], "");
        }
        else if (request_id == gHttpRequestId2)
        {
            if (status == 200 && llSubStringIndex(body, "<item>") != -1)
            {
                string commitData = cutString(body, "item");
                gBuildText += "\n---\n" + cutString(commitData, "title");
                gBuildText += "\n" + cutString(commitData, "link");
                gBuildText += "\n" + cutString(commitData, "pubDate");
            }
            llSetText(gBuildText, <1,1,1>, 1);
        }
    }

}

 

Edited by panterapolnocy
  • Like 2
Link to comment
Share on other sites

19 hours ago, panterapolnocy said:

If by "grid status" you understand users online and for example last report posted on https://status.secondlifegrid.net/ then this thingy may help you to get started with your "digital clock" project. That is also a crude example of parsing contents of the response body @Wulfie Reanimator was talking about few messages above.

 


key gHttpRequestId1;
key gHttpRequestId2;
string gBuildText;

checkData()
{
    gBuildText = "";
    gHttpRequestId1 = llHTTPRequest("http://secondlife.com/xmlhttp/secondlife.php", [HTTP_BODY_MAXLENGTH, 4096], "");
}

string cutString(string theData, string theTag)
{
    integer cutStart = llSubStringIndex(theData, "<" + theTag + ">") + llStringLength("<" + theTag + ">");
    integer cutEnd = llSubStringIndex(theData, "</" + theTag + ">") - 1;
    return llGetSubString(theData, cutStart, cutEnd);
}

default
{

    state_entry ()
    {
        llSetTimerEvent(3600);
        checkData();
    }

    on_rez(integer sp)
    {
        llResetScript();
    }

    timer()
    {
        checkData();
    }

    touch_start(integer sp)
    {
        key targetAvatar = llDetectedKey(0);
        if (llGetAgentSize(targetAvatar) != ZERO_VECTOR)
        {
            llRegionSayTo(targetAvatar, 0, gBuildText);
        }
        else
        {
            llInstantMessage(targetAvatar, gBuildText);
        }
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == gHttpRequestId1)
        {
            gBuildText += "Updated: " + llGetTimestamp();
            if (status == 200 && llSubStringIndex(body, "<status>") != -1)
            {
                gBuildText += "\nGrid: " + cutString(body, "status");
                gBuildText += " | Inworld: " + cutString(body, "inworld");
                gBuildText += "\nSignups: " + cutString(body, "signups");
                gBuildText += " | Logged in past 60 days: " + cutString(body, "logged_in_last_60");
            }
            gHttpRequestId2 = llHTTPRequest("http://status.secondlifegrid.net/history.rss", [HTTP_BODY_MAXLENGTH, 4096], "");
        }
        else if (request_id == gHttpRequestId2)
        {
            if (status == 200 && llSubStringIndex(body, "<item>") != -1)
            {
                string commitData = cutString(body, "item");
                gBuildText += "\n---\n" + cutString(commitData, "title");
                gBuildText += "\n" + cutString(commitData, "link");
                gBuildText += "\n" + cutString(commitData, "pubDate");
            }
            llSetText(gBuildText, <1,1,1>, 1);
        }
    }

}

this is what I am after but I would like it on the prim like this is this possible? I  do like how you added the signups as well as the how many users are inworld as well

 

photo.png

Edited by meady212
Link to comment
Share on other sites

hey guys just an update i have been at this for hours and i keep getting an error when entering the text into the Xyzzy text board (81,4) error:syntax error I am trying to finish off the script with no luck can someone please look over this for me and finish this off thank you in short  I am trying to close the script bellow  is the script

//This program is an example of how Xyzzytext can work!
//XyzzyChat - Local Chat to Text Board v1.0 by Traven Sachs
//Free to use as you wish!  (Credit would be nice... ;-> )

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;

key gHttpRequestId1;
key gHttpRequestId2;
string gBuildText;

checkData()
{
    gBuildText = "";
    gHttpRequestId1 = llHTTPRequest("http://secondlife.com/xmlhttp/secondlife.php", [HTTP_BODY_MAXLENGTH, 4096], "");
}

string cutString(string theData, string theTag)
{
    integer cutStart = llSubStringIndex(theData, "<" + theTag + ">") + llStringLength("<" + theTag + ">");
    integer cutEnd = llSubStringIndex(theData, "</" + theTag + ">") - 1;
    return llGetSubString(theData, cutStart, cutEnd);
}

default
{

    state_entry ()
    {
        llSetTimerEvent(3600);
        checkData();
    }

    on_rez(integer sp)
    {
        llResetScript();
    }

    timer()
    {
        checkData();
    }

    touch_start(integer sp)
    {
        key targetAvatar = llDetectedKey(0);
        if (llGetAgentSize(targetAvatar) != ZERO_VECTOR)
        {
            llRegionSayTo(targetAvatar, 0, gBuildText);
        }
        else
        {
            llInstantMessage(targetAvatar, gBuildText);
        }
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == gHttpRequestId1)
        {
            gBuildText += "Updated: " + llGetTimestamp();
            if (status == 200 && llSubStringIndex(body, "<status>") != -1)
            {
                gBuildText += "\nGrid: " + cutString(body, "status");
                gBuildText += " | Inworld: " + cutString(body, "inworld");
                gBuildText += "\nSignups: " + cutString(body, "signups");
                gBuildText += " | Logged in past 60 days: " + cutString(body, "logged_in_last_60");
            }
            gHttpRequestId2 = llHTTPRequest("http://status.secondlifegrid.net/history.rss", [HTTP_BODY_MAXLENGTH, 4096], "");
        }
        else if (request_id == gHttpRequestId2)
        {
            if (status == 200 && llSubStringIndex(body, "<item>") != -1)

    }
}

Link to comment
Share on other sites

You're  missing a curly bracket to close your last else if test (plus whatever that test was meant to trigger).  Add them and things should work.

BTW, I know that Xyzzy text has been around for a long time in various versions, but I think you'll probably find Furware Text easier to use.  

Edited by Rolig Loon
Cleaner wording
Link to comment
Share on other sites

9 hours ago, Rolig Loon said:

You're  missing a curly bracket to close your last else if test (plus whatever that test was meant to trigger).  Add them and things should work.

BTW, I know that Xyzzy text has been around for a long time in various versions, but I think you'll probably find Furware Text easier to use.  

 

thanks again for the reply from where do I put the curly bracket when i do this i get another error

Link to comment
Share on other sites

Take a good look at the code you posted.

19 hours ago, meady212 said:

else if (request_id == gHttpRequestId2)
        {
            if (status == 200 && llSubStringIndex(body, "<item>") != -1)

There's nothing following that second  if test and the first one opens with a curly bracket that is never closed.  You obviously meant to finish writing the code, but never did.  Nearly everyone I know forgets to match brackets or parentheses occasionally.  It's a pretty common mistake.  That's where an editor like Sublime Text, which highlights matching brackets for you, can help.  It won't help you with missing a whole block of code, though.  ;)

Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

Take a good look at the code you posted.

There's nothing following that second  if test and the first one opens with a curly bracket that is never closed.  You obviously meant to finish writing the code, but never did.  Nearly everyone I know forgets to match brackets or parentheses occasionally.  It's a pretty common mistake.  That's where an editor like Sublime Text, which highlights matching brackets for you, can help.  It won't help you with missing a whole block of code, though.  ;)

that is fixed but now I get    an error with this code gBuildText += \nGrid: " + cutString(body,"status")

I dont see anything wrong with this line do you?

Link to comment
Share on other sites

I added the quotation mark and I am getting the same error

 

http_response(key request_id, integer status, list metadata, string body)
    {
        if ("request_id == gHttpRequestId1)
        {
            gBuildText += Updated: + llGetTimestamp();
            if (status == 200 && llSubStringIndex(body, "<status>") != -1)
            {
                gBuildText += " \nGrid: " + cutString(body, "status");
                gBuildText += " | Inworld: " + cutString(body, "inworld");
                gBuildText += "\nSignups: " + cutString(body, "signups");
                gBuildText += " | Logged in past 60 days: " + cutString(body, "logged_in_last_60");
            }
            gHttpRequestId2 = llHTTPRequest("http://status.secondlifegrid.net/history.rss", [HTTP_BODY_MAXLENGTH, 4096], "");
        }
        else if (request_id == gHttpRequestId2)
        {
            if (status == 200 && llSubStringIndex(body, "<item>") != -1)

    }
 
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1401 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...