Difference between revisions of "LibraryDisplayLandScreenshot"

From Second Life Wiki
Jump to navigation Jump to search
(syntax error plus a little house keepng)
Line 5: Line 5:


Edits:
Edits:
2/19/2010 - Erased my own land's key from the code, forgot to omit this on submission.
*2/19/2010 - Erased my own land's key from the code, forgot to omit this on submission.
*10/4/2010 (Cerise) - whacked a typo and shuffled some deck chairs


<lsl>
<lsl>// Credit goes to Jana Kamachi/Solar Alter
// Credit goes to Jana Kamachi/Solar Alter
// for discovering this concept first  
// for discovering this concept first  
// and taking it beyond just displaying the profile picture
// and taking it beyond just displaying the profile picture
Line 14: Line 14:
// and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile
// and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile
// for further information
// for further information
 
/*
/*
     Modified by Jon Desmoulins to use the new PARCEL_DETAILS_ID
     Modified by Jon Desmoulins to use the new PARCEL_DETAILS_ID
     to fetch the image that displays on the world.secondlife.com pages
     to fetch the image that displays on the world.secondlife.com pages
     It's a little hacky, but it works.
     It's a little hacky, but it works.
*/  
*/
 
string LAND_URL = "http://world.secondlife.com/place/";  //Base URL for world search
string gLandUrl = "http://world.secondlife.com/place/";  //Base URL for world search
key WHITE_DEFAULT_TEXTURE = "5748decc-f629-461c-9a36-a35a221fe21f"; //Use this texture key by default
string gMetaTag = "<meta name=\"imageid\" content=\""; // tag that will contain the texture UUID
integer gMetaTagLength;


ResetTextures()
{
    llSetTexture(TEXTURE_BLANK, ALL_SIDES);
}
default
default
{
{  
   
     state_entry()
     state_entry()
     {
     {
         llSetText("", <1,0,0>, 1.0); // Erase hover text
         ResetTextures();
         llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
         gMetaTagLength = llStringLength(gMetaTag);
     }
     }
   
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {      
     {
         llOwnerSay(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]),0));
         string requestUrl = gLandUrl + (string)llList2Key(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]), 0);
         llHTTPRequest(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]) ,[],"");         
        llOwnerSay(requestUrl);
         llHTTPRequest(requestUrl, [], "");         
     }
     }
     on_rez(integer start_param)
     on_rez(integer start_param)
     {
     {
         llSetText("", <1,0,0>, 1.0); // Erase hover text
         ResetTextures();
        llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
     }
     }
   
     http_response(key request_id,integer status, list metadata, string body)
     http_response(key request_id,integer status, list metadata, string body)
     {
     {
        // If the profile has no picture the image name will be
         if (status == 200)
        // http://world.secondlife.com/images/blank.jpg
         if (llSubStringIndex(body, "blank.jpg") == -1) // If a profile picture exists
         {
         {
             // Find starting point of the land picture UUID
             // Find starting point of the land picture UUID
             integer start_of_UUID = llSubStringIndex(body,"<meta name=\"imageid\" content=\"") + llStringLength("<meta name=\"imageid\" content=\"");
             integer uuidStart = llSubStringIndex(body, gMetaTag) + gMetaTagLength;
            // Find ending point of land picture UUID
            integer end_of_UUID = llSubStringIndex(body,"/");
             // Parse out land UUID from the body
             // Parse out land UUID from the body
             string profile_pic = llGetSubString(body, start_of_UUID, end_of_UUID);
             string parcelImage = llGetSubString(body, uuidStart, uuidStart + 35);
             // Set the sides of the prim to the picture
   
           
             // If the parcel has no picture the image will be NULL_KEY or "".
            //Parse some more, we need to dig deeper to get the key.
             if ((llGetSubString(parcelImage, 0, 0) == "\"") || (parcelImage == NULL_KEY)) {
             integer start = llSubStringIndex(profile_pic,"<!DOCTYPE html PUBLIC \"-/") + llStringLength("<!DOCTYPE html PUBLIC \"-/");
                llOwnerSay("No image for this parcel"); // Tell the avatar they have no picture
            integer end = llSubStringIndex(profile_pic,"\" />");          
                ResetTextures();
            string landpic = llGetSubString(profile_pic, start,end - 1);
             }
              
             else
             //Voila!
             {
             llSetTexture((key)landpic, ALL_SIDES);          
                llOwnerSay("Found parcel image " + parcelImage);
                llSetTexture(parcelImage, ALL_SIDES);
            }
         }
         }
         else
         else
         {
         {
             llWhisper(0, "You have no land picture"); // Tell the avatar they have no picture
             llOwnerSay("Could not retrieve parcel page");
             llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
             ResetTextures();
         }
         }
     }
     }
}
}</lsl>
</lsl>

Revision as of 00:38, 4 October 2010

This is nothing special, but it gets the job done. :) --Jon Desmoulins 17:49, 16 February 2010 (UTC)

NOTE: Your location has to be in the search for this to work. Also, it may take some time for your location to appear in search if you just checked the "Show in Search" button in your land settings. (I forget the cache time)

Edits:

  • 2/19/2010 - Erased my own land's key from the code, forgot to omit this on submission.
  • 10/4/2010 (Cerise) - whacked a typo and shuffled some deck chairs

<lsl>// Credit goes to Jana Kamachi/Solar Alter // for discovering this concept first // and taking it beyond just displaying the profile picture // see http://forums.secondlife.com/showthread.php?t=225460 // and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile // for further information

/*

   Modified by Jon Desmoulins to use the new PARCEL_DETAILS_ID
   to fetch the image that displays on the world.secondlife.com pages
   It's a little hacky, but it works.
  • /

string gLandUrl = "http://world.secondlife.com/place/"; //Base URL for world search string gMetaTag = "<meta name=\"imageid\" content=\""; // tag that will contain the texture UUID integer gMetaTagLength;

ResetTextures() {

   llSetTexture(TEXTURE_BLANK, ALL_SIDES);

}

default {

   state_entry()
   {
       ResetTextures();
       gMetaTagLength = llStringLength(gMetaTag);
   }

   touch_start(integer num_detected)
   {
       string requestUrl = gLandUrl + (string)llList2Key(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]), 0);
       llOwnerSay(requestUrl);
       llHTTPRequest(requestUrl, [], "");        
   }
   on_rez(integer start_param)
   {
       ResetTextures();
   }

   http_response(key request_id,integer status, list metadata, string body)
   {
       if (status == 200)
       {
           // Find starting point of the land picture UUID
           integer uuidStart = llSubStringIndex(body, gMetaTag) + gMetaTagLength;
           // Parse out land UUID from the body
           string parcelImage = llGetSubString(body, uuidStart, uuidStart + 35);
   
           // If the parcel has no picture the image will be NULL_KEY or "".
           if ((llGetSubString(parcelImage, 0, 0) == "\"") || (parcelImage == NULL_KEY)) {
               llOwnerSay("No image for this parcel"); // Tell the avatar they have no picture
               ResetTextures();
           }
           else
           {
               llOwnerSay("Found parcel image " + parcelImage);
               llSetTexture(parcelImage, ALL_SIDES);
           }
       }
       else
       {
           llOwnerSay("Could not retrieve parcel page");
           ResetTextures();
       }
   }

}</lsl>