Difference between revisions of "LlMapDestination"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 15: Line 15:
* if {{LSLP|simname}} is {{HoverText|omitted|an empty string: {{String}}}} or invalid, the map will open centered on object, but {{LSLP|pos}} will not be highlighted. Since this function requests the client to perform a task, there is no way for script to know if it has failed.
* if {{LSLP|simname}} is {{HoverText|omitted|an empty string: {{String}}}} or invalid, the map will open centered on object, but {{LSLP|pos}} will not be highlighted. Since this function requests the client to perform a task, there is no way for script to know if it has failed.
|constants
|constants
|examples=<lsl>//Click the object this script is in and your map opens up in the middle of Oasis.
|examples=
default
{
    touch_start(integer num)
    {
          llMapDestination("Oasis", <128, 128, 0>, ZERO_VECTOR);
    }
}</lsl>
<lsl>
<lsl>
// Get a teleport map, via touch_start, from the name of the first landmark in inventory.
string simName = "Help Island Public";
// NOTE:  Requires a landmark that contains name, region and position data.
vector tpDest = <128.0, 128.0, 24.0>;
//        The correct format is "name, region (x, y, z)". If a landmark's
vector lookAt = ZERO_VECTOR;
//        name is too long the position data is truncated from the end,
 
//        which will cause the position to be wrong.
default
default
{
{
    touch_start(integer num)
    state_entry()
    {
    {
          // Parse the name of the first landmark found in inventory into a list using
        // set white, opaque floattext with teleport destination
          // commas as separators.
        llSetText("click to teleport\nto '" + simName + "'", <1.0, 1.0, 1.0>, (float)TRUE);
          list lstTemp = llParseString2List(llGetInventoryName(
    }
              INVENTORY_LANDMARK,0),[","],[]);
 
    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);


          // Get list length and subtract 3 to get the correct element containing
        string old_url_prefix = "http://slurl.com/secondlife/";
          // the region name. Moving backward from the end of the list keeps
        string new_url_prefix = "http://maps.secondlife.com/secondlife/";
          // commas in the landmark name from giving us grief with misaligned
        string url_suffix = llEscapeURL(simName) + "/" + (string)llRound(tpDest.x) + "/" + (string)llRound(tpDest.y) + "/" + (string)llRound(tpDest.z);
          // and incorrect data.
          integer intElement = llGetListLength(lstTemp)-3;


          // Get the region name from the list element, eliminating unneeded
        llInstantMessage(id, old_url_prefix + url_suffix);
          // characters in the string and trimming leading/trailing spaces.
        llInstantMessage(id, new_url_prefix + url_suffix);
          string strSimname = llStringTrim(llGetSubString(llList2String(lstTemp,
              intElement),0,llSubStringIndex(llList2String(lstTemp,intElement),"(")-1),
              STRING_TRIM);  


          // The vector is pulled from the landmark name, based on the
        llMapDestination(simName, tpDest, lookAt);
          // position of "(" in the string starting with the next
    }
          // character and ending with the second to the last character.
}
          vector vecVector = (vector)("<"+llGetSubString(llGetInventoryName(
</lsl>
              INVENTORY_LANDMARK,0),llSubStringIndex(llGetInventoryName(
              INVENTORY_LANDMARK,0),"(")+1,-2)+">");
         
          // Bring up the teleport map using the data we extracted.
          llMapDestination(strSimname,vecVector,ZERO_VECTOR);
    }
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 13:42, 23 September 2012

Summary

Function: llMapDestination( string simname, vector pos, vector look_at );
1.0 Forced Delay
10.0 Energy

Opens world map centered on simname with pos highlighted.
Only works for scripts attached to avatar, or during touch events.

• string simname Region name
• vector pos position in region coordinates
• vector look_at position in region coordinates (not used)

(NOTE: look_at currently does nothing)

Caveats

  • This function causes the script to sleep for 1.0 seconds.
  • if simname is omitted or invalid, the map will open centered on object, but pos will not be highlighted. Since this function requests the client to perform a task, there is no way for script to know if it has failed.

Examples

<lsl> string simName = "Help Island Public"; vector tpDest = <128.0, 128.0, 24.0>; vector lookAt = ZERO_VECTOR;

default {

   state_entry()
   {
       // set white, opaque floattext with teleport destination
       llSetText("click to teleport\nto '" + simName + "'", <1.0, 1.0, 1.0>, (float)TRUE);
   }
   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       string old_url_prefix = "http://slurl.com/secondlife/";
       string new_url_prefix = "http://maps.secondlife.com/secondlife/";
       string url_suffix = llEscapeURL(simName) + "/" + (string)llRound(tpDest.x) + "/" + (string)llRound(tpDest.y) + "/" + (string)llRound(tpDest.z);
       llInstantMessage(id, old_url_prefix + url_suffix);
       llInstantMessage(id, new_url_prefix + url_suffix);
       llMapDestination(simName, tpDest, lookAt);
   }

}

</lsl>

Notes

  • pos will work with Region coordinates not inside simname. (like those returned by llRequestInventoryData)
  • if called from non touch events, it only works for the owner.
  • if called from touch, it may only work for the first or last touch in the event queue (example: num_touched > 1)
  • if called inside an attachment, it only works for the owner.

See Also

Functions

•  llRequestInventoryData

Deep Notes

Signature

function void llMapDestination( string simname, vector pos, vector look_at );