User:Opensource Obscure/FFHUD

From Second Life Wiki
< User:Opensource Obscure
Revision as of 08:38, 13 June 2008 by Opensource Obscure (talk | contribs) (New page: {{LSL Header}} '''~ FFHUD vx.x. by Opensource Obscure ~'''<br> '''~ a simple FriendFeed HUD ~''' '''this code is probably horrible and flawed''' '''use of this script may be a violation...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

~ FFHUD vx.x. by Opensource Obscure ~
~ a simple FriendFeed HUD ~

this code is probably horrible and flawed

use of this script may be a violation of ToS
help to clearify this is welcome

Set-up, configuration and operation Help: http://wiki.secondlife.com/wiki/User_talk:Opensource_Obscure

Profile: http://wiki.secondlife.com/wiki/User:Opensource_Obscure

How it works

  • edit script 1 with your FriendFeed account data
  • put script 1 in a prim
  • put script 2 in another prim
  • link the prims
  • wear the object as an HUD
________
|   |   |
| 1 | 2 |
|___|___|
  • touch button 2 to get info about the parcel you're in and agents around
  • touch button 1 to publish a post on FriendFeed that includes available info about the parcel (name, description, owner/owner group profile image)
  • say this in chat to publish a post on FriendFeed with a message and info about the parcel (name, description, owner/owner group profile image)
/8 This is my message

FFHUD, script 1/2: FFHUD

<lsl>

// your FriendFeed username are here: https://friendfeed.com/account/api string user=""; // your FriendFeed username string ffkey=""; // your FriendFeed key

string baseurl="@friendfeed.com/api/share"; string text; string url; string message; string desc;

azzera() {

   text="";
   url="";
   message="";
   desc = "";

}

string strReplace(string source, string pattern, string replace) {

   while (llSubStringIndex(source, pattern) > -1) {
       integer len = llStringLength(pattern);
       integer pos = llSubStringIndex(source, pattern);
       if (llStringLength(source) == len) { source = replace; }
       else if (pos == 0) { source = replace+llGetSubString(source, pos+len, -1); }
       else if (pos == llStringLength(source)-len) { source = llGetSubString(source, 0, pos-1)+replace; }
       else { source = llGetSubString(source, 0, pos-1)+replace+llGetSubString(source, pos+len, -1); }
   }
   return source;

}


string regionname() {

   string region=llDumpList2String(llParseString2List(llGetRegionName(),[" "],[]),"+");  
   return region;

}

string parcelname() {

   list lstParcelName=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]);                
   string a = (string)lstParcelName;
   string name = llDumpList2String(llParseString2List(a,[" "],[]),"+"); 
   name = strReplace(name,"&","and");
   return name; 

}

string parceldesc() {

   list lstParcelDesc=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_DESC]);                
   string a = (string)lstParcelDesc;
   if(a != "00000000-0000-0000-0000-000000000000")
   {
       desc = llDumpList2String(llParseString2List(a,[" "],[]),"+");        
   }
   else
   {
       desc = "";
   }
   desc = strReplace(desc,"&","and");
   return desc;   

}

string slurl() {

   string simname = llDumpList2String(llParseString2List(llGetRegionName(),[" "],[]),"+");
   string regionname = simname;
   vector detectedPos = llGetRootPosition();        
   string sx = (string)llRound(detectedPos.x);
   string sy = (string)llRound(detectedPos.y);
   string sz = (string)llRound(detectedPos.z);
   string url = "http://slurl.com/secondlife/";  
   url += simname; 
   url += "/" + sx + "/" + sy + "/" + sz ; 
   return url;   

}

default {

   state_entry()
   {
       azzera(); 
       llListen(8, "", llGetOwner(), "");           
   }
   touch_start(integer total_number)
   {
       azzera();
       llMessageLinked(2, 1, "", NULL_KEY);        
   }
   
   
   listen(integer channel, string name, key id, string message)
   {
       azzera();
       llMessageLinked(2, 1, "", NULL_KEY);
       text = "+-+MY MESSAGE:+" + message;
       text = strReplace(text,"&","and");
   }
   link_message(integer sender_num, integer num, string str, key id)    
   {
       string imageurl = "http://secondlife.com/app/image/" + (string)id + "/2";        
       text = llDumpList2String(llParseString2List(text,[" "],[]),"+");
       string post = 
       "http://" + 
       user + 
       ":" + 
       ffkey + 
       baseurl + 
       "?title=" + 
       regionname() +
       "+-+" +
       parcelname() +
       "&link=" + 
       llEscapeURL(slurl()) + 
       "&comment=" +
       "PARCEL+INFO:+" +
       parceldesc() +    
       text + 
       "&image0_url=" + 
       llEscapeURL(imageurl);
       // post = strReplace(post,"&","and");
       llHTTPRequest(post, [HTTP_METHOD,"POST"], "");        
   }


   http_response(key request_id, integer status, list metadata, string body)
   {
       {
          llOwnerSay("Message sent to http://friendfeed.com/" + user);
       }
   }     
   
   


}

</lsl>


FFHUD, script 2/2: PARCEL INFO

<lsl>

string ownerurl = "http://world.secondlife.com/resident/"; string groupurl = "http://world.secondlife.com/group/"; string code1 = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/"; string code2 = "\" class=\"parcelimg\" />"; key texturedefault = "19920f4f-d667-ab18-7234-af4623b52065"; string desc; float scanradius = 96.0;

string parcelname() {

   list lstParcelName=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]);                
   string a = (string)lstParcelName;
   string name = llDumpList2String(llParseString2List(a,[" "],[]),"+"); 
   return name; 

}


string parceldesc() {

   list lstParcelDesc=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_DESC]);                
   string a = (string)lstParcelDesc;  
   if(a != "00000000-0000-0000-0000-000000000000")
   {
       desc = llDumpList2String(llParseString2List(a,[" "],[]),"+") + "+-+";                
   } 
   else
   {
       desc = "";
   } 
   return desc;   

}


string parcelowner() {

   list lstParcelOwner=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_OWNER]);                
   string uuid = (string)lstParcelOwner;    
   return uuid;    

}


string parcelgroup() {

   list lstParcelGroup=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_GROUP]);              
   string uuid = (string)lstParcelGroup;
   return uuid;

}


infoparcel() {

   llOwnerSay("parcel name =" + parcelname());
   llOwnerSay("parcel desc =" + parceldesc());
   llOwnerSay("parcel owner = " + "secondlife:///app/agent/" + parcelowner() + "/about");   
   llOwnerSay("parcel group = "  + "secondlife:///app/group/" + parcelgroup() + "/about");
   llSensor("", NULL_KEY, AGENT, scanradius, PI);

}


default {

   state_entry()
   {
       llSetTexture(texturedefault, ALL_SIDES);        
   }
   link_message(integer sender_num, integer num, string str, key id)    
   {
       string a = parcelgroup();
       if(a == "00000000-0000-0000-0000-000000000000")
       {
           llOwnerSay("Proprieta' del resident " + parcelowner());    
           llHTTPRequest( ownerurl + parcelowner(),[HTTP_METHOD,"GET"],"");               
       }  
       else
       {
           llOwnerSay("Proprieta' del gruppo " + parcelgroup());            
           llHTTPRequest( groupurl + parcelgroup(),[HTTP_METHOD,"GET"],"");            
       }
   }
  
  
   touch_start(integer total_number)
   { 
       infoparcel();
   }
   
   
   http_response(key req,integer stat, list met, string body)
   {    
       key texture = (key)llGetSubString(body,llSubStringIndex(body, code1)+llStringLength(code1),llSubStringIndex(body,code2)-3); 
       llSetTexture(texture, ALL_SIDES);
       llMessageLinked(1, 2, "", texture);     
   }
   
   
   sensor(integer total_number)
   {
       llOwnerSay((string)total_number + " avatar" + " in " + (string)scanradius+ " meters");
       integer i;
       for (i = 0; i < total_number; i++)
       {
           llOwnerSay(llDetectedName(i) + " > secondlife:///app/agent/" + (string)llDetectedKey(i) + "/about");             
       }
    
   }
   no_sensor()
   {
       llOwnerSay("nobody hereright now (radius=" + (string)scanradius + " meters)");
   }
   

}


</lsl>