Difference between revisions of "BuildSlurl (NewAge)"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{delete|The name of this page is misleading and the content is (for want of kinder words) not terribly helpful. The content could be simply edited to provide a ''better'' example/function but would remain confusingly/inappropriately named. Surely it is best that ONLY genuine Linden Library functions have pages titled in such a way (with the "ll" prefix).}}
{{LSL Header}}
 
====llSLURL====
 
A way of creating SLURL's by using a pre-made function;
A way of creating SLURL's by using a pre-made function;
  llSLURL(string region_name, vector pos);
  BuildSlurl(string region_name, vector pos);


''Pre-made Function''
''Pre-made Function''


<lsl>
<source lang="lsl2">
string llSLURL(string region_name, vector pos)
string BuildSlurl(string region_name, vector pos){
{
     return "secondlife://" + llEscapeURL(region_name)  
     string slurl = "secondlife://";
             + "/"+ (string)((integer)pos.x)  
    list parse = llParseString2List(region_name, [" "], []);
            + "/"+ (string)((integer)pos.y)  
    if(llGetListLength(parse) != 0)
            + "/"+ (string)(llCeil(pos.z));
    {
}</source>
        integer i = 0;
        integer all = llGetListLength(parse)-1;
        do
        {
            if(llStringLength(llList2String(parse, i)) > 0)
            {
                slurl += llList2String(parse, i);
                if((i != all)||(i < all))
                {
                    slurl += "%20";
                }
             }
        }while(i++<all);
    }
    else
    {
        slurl += region_name;
    }
    parse = llParseString2List((string)pos, ["<", ",", ">"], []);
    slurl+="/"+(string)((integer)llList2String(parse, 0))+"/"+(string)((integer)llList2String(parse, 1))+"/"+(string)((integer)llList2String(parse, 2));
    return slurl;
}
</lsl>


----
----
Line 43: Line 17:
''Example Script''
''Example Script''


<lsl>
<source lang="lsl2">
string llSLURL(string region, vector pos)
string BuildSlurl(string region_name, vector pos){
{
     return "secondlife://" + llEscapeURL(region_name)  
     string slurl = "secondlife://";
             + "/"+ (string)((integer)pos.x)  
    list parse = llParseString2List(region, [" "], []);
            + "/"+ (string)((integer)pos.y)  
    if(llGetListLength(parse) != 0)
            + "/"+ (string)(llCeil(pos.z));
    {
        integer i = 0;
        integer all = llGetListLength(parse)-1;
        do
        {
            if(llStringLength(llList2String(parse, i)) > 0)
            {
                slurl += llList2String(parse, i);
                if((i != all)||(i < all))
                {
                    slurl += "%20";
                }
             }
        }while(i++<all);
    }
    else
    {
        slurl += region_name;
    }
    parse = llParseString2List((string)pos, ["<", ",", ">"], []);
    slurl+="/"+(string)((integer)llList2String(parse, 0))+"/"+(string)((integer)llList2String(parse, 1))+"/"+(string)((integer)llList2String(parse, 2));
    return slurl;
}
}


Line 77: Line 29:
     touch_start(integer x)
     touch_start(integer x)
     {
     {
         llWhisper(0, llSLURL(llGetRegionName(), llGetPos()));
         llWhisper(0, BuildSlurl(llGetRegionName(), llGetPos()));
         //Returns slurl like this;
         //Returns slurl like this;
         //      secondlife://Phoenix%20Rising/214/160/24
         //      secondlife://Phoenix%20Rising/214/160/24
     }
     }
}
}
</lsl>
</source>

Latest revision as of 18:44, 24 January 2015

A way of creating SLURL's by using a pre-made function;

BuildSlurl(string region_name, vector pos);

Pre-made Function

string BuildSlurl(string region_name, vector pos){
    return "secondlife://" + llEscapeURL(region_name) 
            + "/"+ (string)((integer)pos.x) 
            + "/"+ (string)((integer)pos.y) 
            + "/"+ (string)(llCeil(pos.z));
}

Example Script

string BuildSlurl(string region_name, vector pos){
    return "secondlife://" + llEscapeURL(region_name) 
            + "/"+ (string)((integer)pos.x) 
            + "/"+ (string)((integer)pos.y) 
            + "/"+ (string)(llCeil(pos.z));
}

default
{
    touch_start(integer x)
    {
        llWhisper(0, BuildSlurl(llGetRegionName(), llGetPos()));
        //Returns slurl like this;
        //       secondlife://Phoenix%20Rising/214/160/24
    }
}