Difference between revisions of "SLURL HUD"

From Second Life Wiki
Jump to navigation Jump to search
(Submitting the SLURL HUD script to the LSL script library)
 
m (Replaced <source> with <syntaxhighlight>)
 
(3 intermediate revisions by 3 users not shown)
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.
<syntaxhighlight lang="lsl2">
string slurl()
{
    string regionname = llGetRegionName();
    vector pos = llGetPos();


<lsl>
    return "http://maps.secondlife.com/secondlife/"
 
        + llEscapeURL(regionname) + "/"
// CODIE'S SLURL HUD SCRIPT - By CodeBastard Redrave
         + (string)llRound(pos.x) + "/"
//
        + (string)llRound(pos.y) + "/"
// Loosely inspired of:
        + (string)llRound(pos.z) + "/";
// http://forums.secondlife.com/showthread.php?t=152021&highlight=slurl+script
}
//
// 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);
     }
     }
}  
}
 
</syntaxhighlight>
</lsl>
 


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

Latest revision as of 03:22, 23 November 2023

Touch to get the SLURL.

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() );
    }
}