Talk:BuildSlurl (NewAge)

From Second Life Wiki
Jump to: navigation, search
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)