Difference between revisions of "SLURL HUD"

From Second Life Wiki
Jump to navigation Jump to search
m
m (simplified example script)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}


When touched, this HUD script sends a SLURL to yourself through IM for logging, sends it to a preconfigured email adress from a notecard, and displays it over the prim.
Touch to get the SLURL.
 
Drop this script in a prim, add a notecard called "emailaddress" with the email address in a single line, and reset the script to load the notecard. Wear it as a HUD. Just touch to get the SLURL.


<lsl>
<lsl>
string slurl()
{
    string regionname = llGetRegionName();
    vector pos = llGetPos();


// CODIE'S SLURL HUD SCRIPT - By CodeBastard Redrave
    return "http://maps.secondlife.com/secondlife/"
//
        + llEscapeURL(regionname) + "/"
// Loosely inspired of:
         + (string)llRound(pos.x) + "/"
// http://forums-archive.secondlife.com/15/c2/152021/1.html
        + (string)llRound(pos.y) + "/"
//
        + (string)llRound(pos.z) + "/";
// USAGE: This script can be worn as a HUD and can be touched to spew a SLURL of your current location through various methods including IM log, Chat, and Email.
}
// For email to work, you only need to set the email adress through the embedded notecard.
// This script is FREE SOFTWARE.
// DO NOT: Sell this script or remove the credits and comments.
// DO: Give away, copy and distribute freely.
string gName = "emailcard";    // name of a notecard in the object's inventory
integer gLine = 0;        // current line number
key gQueryID; // id used to identify dataserver queries
string emailaddress = "";
integer emailactivated = TRUE; // set to FALSE to deactivate email
 
//function that spews the actual SLURL to a bunch of places
 
spewslurl(string emailaddress) {
 
        string regionname = llDumpList2String(llParseString2List(llGetRegionName(),[" "],[]),"%20");
         vector pos = llGetPos();
        integer x = (integer)pos.x;
        integer y = (integer)pos.y;
        integer z = (integer)pos.z;
       
        string slurl = "http://slurl.com/secondlife/"+regionname+"/"+(string)x+"/"+(string)y+"/"+(string)z+"/";


        //spews the stuff everythere!
        llOwnerSay(slurl);
        llInstantMessage(llGetOwner(),slurl);
        llSetText(slurl,<1.0,1.0,1.0>,1.0);
       
            if (emailactivated) {
                //tell the owner where this mail is going to be sent
                llOwnerSay("Email set to:" + emailaddress + "\n");
                llEmail(emailaddress, slurl, slurl);
                //tell the owner when this mail has been sent
                llOwnerSay("Email sent to:" + emailaddress + "\n");
            }
         
}
default
default
{
{
 
     touch_start(integer num_detected)
     state_entry() {
     {
        gQueryID = llGetNotecardLine(gName, gLine);    // request first line
         // PUBLIC_CHANNEL has the integer value 0
        }
         llSay(PUBLIC_CHANNEL, slurl() );
 
     dataserver(key query_id, string data) {
         if (query_id == gQueryID) {
            if (data != EOF) {    // not at the end of the notecard
                //llSay(0, (string)gLine+": "+data);    // output the line for debugging purposes
                emailaddress = data;
                ++gLine;                // increase line count
                gQueryID = llGetNotecardLine(gName, gLine);    // request next line
             
            }
        }
    }
   
   
    touch_start(integer t) {
         llSay(0, "OPC SLURL HUD" );
        llSay(0, "By CodeBastard Redgrave\n" )
     
        spewslurl(emailaddress);
     }
     }
}  
}
 
</lsl>
</lsl>


{{LSLC|Examples}}
{{LSLC|Examples}}
{{LSLC|Library}}
{{LSLC|Library}}

Revision as of 14:58, 7 October 2012

Touch to get the SLURL.

<lsl> string slurl() {

   string regionname = llGetRegionName();
   vector pos = llGetPos();
   return "http://maps.secondlife.com/secondlife/"
       + llEscapeURL(regionname) + "/"
       + (string)llRound(pos.x) + "/"
       + (string)llRound(pos.y) + "/"
       + (string)llRound(pos.z) + "/";

}

default {

   touch_start(integer num_detected)
   {
       // PUBLIC_CHANNEL has the integer value 0
       llSay(PUBLIC_CHANNEL, slurl() );
   }

} </lsl>