Difference between revisions of "Talk:BuildSlurl (NewAge)"

From Second Life Wiki
Jump to navigation Jump to search
(The page of which this is the talk (O.o) depicts what I considered to be an inefficient method of creating a slurl from string & vector data. I posted an alt suggestion.)
 
(→‎Alternative slurl type links: Changed function since being educated by Rand & Babbage (thanx again))
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== [[llEscapeURL]] ==
{{KBnote|This page has been moved from [[llSLURL (NewAge)]]. See [[Suggested For Deletion/LlSLURL (NewAge)|here]] for the related discussion.}}
== Alternative slurl type links ==


The use of [[llEscapeURL]] would/could simplify this function a great deal.
A thrown-together script example showing 3 different types of destination/teleport links.
 
As for breaking the vector pos up into integers...why not make it nice and simple? If the data arrives at the function as a vector without error, we know exactly what we're dealing with and thus exactly how. [[llRound]] may not be ''the ideal'' way of integerizing the floats but it is clean.
 
<lsl>string SLURL(string region, vector pos)
{
    return (llEscapeURL(region) + "/" + ((string)llRound(pos.x)) + "/" + ((string)llRound(pos.y)) + "/" + ((string)llRound(pos.z)));
}</lsl>
 
I couldn't help but fiddle about a bit. Of course the end use dictates so much how to best write any script so the script below is just the result of my fiddling before it dawned on me how many other ways the resulting object could function...I'm not writing all of 'em!


<lsl>string message_1 = "Click this link for destination information and teleport option:\n";
<lsl>string message_1 = "Click this link for destination information and teleport option:\n";
Line 30: Line 22:
string SLURL(string region, vector pos)
string SLURL(string region, vector pos)
{
{
     return (llEscapeURL(region) + "/" + ((string)llRound(pos.x)) + "/" + ((string)llRound(pos.y)) + "/" + ((string)llRound(pos.z)));
     return (llEscapeURL(region) + "/" + ((string)((integer)pos.x)) + "/" + ((string)((integer)pos.y)) + "/" + ((string)llCeil(pos.z)));
}
}


Line 74: Line 66:
         }
         }
     }
     }
}</lsl>-- '''[[User:Fred_Gandt|Fred Gandt]]''' <sup><small>([[User talk:Fred_Gandt|talk]]|[[Special:Contributions/Fred_Gandt|contribs]])</small></sup> 11:29, 28 August 2010 (UTC)
}</lsl>-- '''[[User:Fred_Gandt|Fred Gandt]]''' <sup><small>([[User talk:Fred_Gandt|talk]]|[[Special:Contributions/Fred_Gandt|contribs]])</small></sup> 19:41, 4 September 2010 (UTC)

Latest revision as of 16:08, 9 September 2010

KBnote.png Note: This page has been moved from llSLURL (NewAge). See here for the related discussion.

Alternative slurl type links

A thrown-together script example showing 3 different types of destination/teleport links.

<lsl>string message_1 = "Click this link for destination information and teleport option:\n";

string message_2 = "Click this link for instant teleport:\n";

string message_3 = "This link can be used on a web site to direct users in-world:\n";

string method_1 = "secondlife://"; // Usable in-world only

string method_2 = "secondlife:///app/teleport/"; // Instant teleport

string method_3 = "http://slurl.com/secondlife/"; // Genuine slurl usable in and out-world

string region_name;

vector coords;

string SLURL(string region, vector pos) {

   return (llEscapeURL(region) + "/" + ((string)((integer)pos.x)) + "/" + ((string)((integer)pos.y)) + "/" + ((string)llCeil(pos.z)));

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & CHANGED_REGION)
       {
           llResetScript();
       }
   }
   state_entry()
   {
       // The user simply adds the destination region name and landing pos as the description of the prim (comma separated).
       list destination = llCSV2List(llGetObjectDesc());
       if(llGetListLength(destination) == 2)
       {
           // Various checks could be employed to varify the user has added the destination to the prim desc correctly (idiot proofing!)
           region_name = llList2String(destination, 0);
           coords = ((vector)llList2String(destination, 1));
           return;
       }
       else
       {
           // Otherwise the destination defaults to the prim position (Useful? Better than nothing).
           region_name = llGetRegionName();
           coords = llGetPos();
       }
   }
   touch_start(integer nd)
   {
       while(nd)
       {
           string dest = SLURL(region_name, coords);
           llInstantMessage(llDetectedKey(--nd), ("\n" + message_1 + method_1 + dest +
                                                  "\n" + message_2 + method_2 + dest +
                                                  "\n" + message_3 + method_3 + dest));
       }
   }

}</lsl>-- Fred Gandt (talk|contribs) 19:41, 4 September 2010 (UTC)