Difference between revisions of "LibraryDisplayLandScreenshot"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with 'This is nothing special, but it gets the job done. :) --~~~~ <lsl> // Credit goes to Jana Kamachi/Solar Alter // for discovering this concept first // and taking it beyond just...')
 
Line 16: Line 16:
*/  
*/  


string LAND_URL = "http://world.secondlife.com/place/";
string LAND_URL = "http://world.secondlife.com/place/"; //Base URL for world search
key WHITE_DEFAULT_TEXTURE = "5748decc-f629-461c-9a36-a35a221fe21f";
key WHITE_DEFAULT_TEXTURE = "5748decc-f629-461c-9a36-a35a221fe21f"; //Use this texture key by default


default
default
Line 30: Line 30:
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {         
     {         
         llOwnerSay(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]),0));
         llOwnerSay(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]),0));
         llHTTPRequest(LAND_URL + "8d1b5ac3-e95f-3104-e678-0b73b481eaab" ,[],"");         
         llHTTPRequest(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]) ,[],"");         
     }
     }
     on_rez(integer start_param)
     on_rez(integer start_param)

Revision as of 13:54, 19 February 2010

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

<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 LAND_URL = "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

default {

   state_entry()
   {
       llSetText("", <1,0,0>, 1.0); // Erase hover text
       llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
   }
   
   touch_start(integer num_detected)
   {        
       llOwnerSay(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]),0));  
       llHTTPRequest(LAND_URL + (string)llList2Key(llGetParcelDetails(llGetPos(),[5]) ,[],"");        
   }
   on_rez(integer start_param)
   {
       llSetText("", <1,0,0>, 1.0); // Erase hover text
       llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
   }
   
   http_response(key request_id,integer status, list metadata, string body)
   {
       // If the profile has no picture the image name will be
       // 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
           integer start_of_UUID = llSubStringIndex(body,"<meta name=\"imageid\" content=\"") + llStringLength("<meta name=\"imageid\" content=\"");
           // Find ending point of land picture UUID
           integer end_of_UUID = llSubStringIndex(body,"/");
           // Parse out land UUID from the body
           string profile_pic = llGetSubString(body, start_of_UUID, end_of_UUID);
           // Set the sides of the prim to the picture
           
           //Parse some more, we need to dig deeper to get the key.
           integer start = llSubStringIndex(profile_pic,"<!DOCTYPE html PUBLIC \"-/") + llStringLength("<!DOCTYPE html PUBLIC \"-/");
           integer end = llSubStringIndex(profile_pic,"\" />");            
           string landpic = llGetSubString(profile_pic, start,end - 1);
           
           //Voila!
           llSetTexture((key)landpic, ALL_SIDES);            
       }
       else
       {
           llWhisper(0, "You have no land picture"); // Tell the avatar they have no picture
           llSetTexture(WHITE_DEFAULT_TEXTURE, ALL_SIDES); // Set to default texture
       }
   }

} </lsl>