Difference between revisions of "LlTeleportAgentGlobalCoords"

From Second Life Wiki
Jump to navigation Jump to search
m (ok, since this is now owner only....changed example script again.....)
Line 16: Line 16:
|examples=<lsl>
|examples=<lsl>
string simName = "Help Island Public";
string simName = "Help Island Public";
vector simGlobalCoords;
vector landingPoint = <128.0, 128.0, 24.0>;
vector landingPoint = <128.0, 128.0, 24.0>;


key avatarToBeTeleported;
key owner;
vector globalSimCoordinates;
 


default
default
Line 26: Line 28:
     {
     {
         llResetScript();
         llResetScript();
    }
    changed(integer change)
    {
        if (change & CHANGED_OWNER)
            llResetScript();
     }
     }


     state_entry()
     state_entry()
     {
     {
        owner = llGetOwner();
        llRequestPermissions(owner, PERMISSION_TELEPORT);
         llRequestSimulatorData(simName, DATA_SIM_POS);
         llRequestSimulatorData(simName, DATA_SIM_POS);
     }
     }
Line 35: Line 46:
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
         avatarToBeTeleported = llDetectedKey(0);
         key id = llDetectedKey(0);


         if (globalSimCoordinates == ZERO_VECTOR)
         if (id == owner)
         {
         {
             llRegionSayTo(avatarToBeTeleported, PUBLIC_CHANNEL,
             if (simGlobalCoords == ZERO_VECTOR)
                 "Configuration error, teleport request has been denied. Please try again!");
            {
             llResetScript();
                 llOwnerSay("Config error, tp request was denied. Please try again!");
                llResetScript();
            }
            else
             {
                llOwnerSay("Teleporting you to: http://maps.secondlife.com/secondlife/"
                    + llEscapeURL(simName) + "/" + (string)llRound(landingPoint.x)
                    + "/" + (string)llRound(landingPoint.y) + "/" + (string)llRound(landingPoint.z) + "/");
 
                llTeleportAgentGlobalCoords(owner, simGlobalCoords, landingPoint, ZERO_VECTOR);
            }
         }
         }
         else
         else
         {
         {
             llRegionSayTo(avatarToBeTeleported, PUBLIC_CHANNEL,
            // llRegionSayTo is faster than llInstantMessage and we can assume
                 "Teleporting you to: http://maps.secondlife.com/secondlife/"
            // that the touching avatar is within the same sim
                + llEscapeURL(simName) + "/" + (string)llRound(landingPoint.x)
 
                + "/" + (string)llRound(landingPoint.y) + "/" + (string)llRound(landingPoint.z) + "/");
             llRegionSayTo(id, PUBLIC_CHANNEL,
            llRequestPermissions(avatarToBeTeleported, PERMISSION_TELEPORT);
                 "Sorry, I can't tp you. You're NOT my owner!");
         }
         }
     }
     }


     run_time_permissions(integer perms)
     run_time_permissions(integer perm)
     {
     {
         if (perms & PERMISSION_TELEPORT)
         // if permission request has been denied (read ! as not)
            llTeleportAgentGlobalCoords(avatarToBeTeleported, globalSimCoordinates, landingPoint, ZERO_VECTOR);
        if (!(perm & PERMISSION_TELEPORT))
         else
         {
             llRegionSayTo(avatarToBeTeleported, PUBLIC_CHANNEL,
             llOwnerSay("I need permissions to teleport you!");
                "Teleport failed, you didn't grant permissions. Please try again!");
            llRequestPermissions(owner, PERMISSION_TELEPORT);
        }
    }


        llResetScript();
//  dataserver event only called if data is returned
    }
//  or in other words, if you request data for a sim that does
//  not exist this event will NOT be called


     dataserver(key query_id, string data)
     dataserver(key query_id, string data)
     {
     {
         globalSimCoordinates = (vector)data;
         simGlobalCoords = (vector)data;
        // llOwnerSay("Sim global coords: " + (string)simGlobalCoords);
     }
     }
}
}

Revision as of 07:21, 27 July 2012

Emblem-important-red.png Pre-release Documentation Warning!

This function is only available in RC LeTigre channel. This documentation was written prior to its final release so it may not match the final implementation.

Summary

Function: llTeleportAgentGlobalCoords( key agent, vector global_coordinates, vector region_coordinates, vector look_at );

Teleports an agent to set of a region_coordinates within a region at the specified global_coordinates. The agent lands facing the position defined by look_at local coordinates. A region's global coordinates can be retrieved using llRequestSimulatorData(region_name, DATA_SIM_POS)

• key agent avatar UUID that is in the same region (avatar to be teleported)
• vector global_coordinates Global coordinates of the destination region. Can be retrieved by using llRequestSimulatorData(region_name, DATA_SIM_POS).
• vector region_coordinates Destination position inside the target region, given in local coordinates.
• vector look_at Location avatar will face after completing the teleport, given in local coordinates.

To run this function the script must request the PERMISSION_TELEPORT permission with llRequestPermissions and it must be granted by agent. The combination of llRequestSimulatorData and llTeleportAgentGlobalCoords allows agents to be teleported to regions by region name.

Caveats

Permissions
  • Once the PERMISSION_TELEPORT permission is granted there is no way to revoke it except from inside the script (for example, with a new llRequestPermissions call) or the script is reset or deleted.
  • This function cannot be used in a script in an object attached using llAttachToAvatarTemp.
  • This function can only teleport the owner of the object.
  • Sitting avatars cannot be teleported using this function. You must llUnSit them first.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> string simName = "Help Island Public"; vector simGlobalCoords;

vector landingPoint = <128.0, 128.0, 24.0>;

key owner;


default {

   on_rez(integer start_param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if (change & CHANGED_OWNER)
           llResetScript();
   }
   state_entry()
   {
       owner = llGetOwner();
       llRequestPermissions(owner, PERMISSION_TELEPORT);
       llRequestSimulatorData(simName, DATA_SIM_POS);
   }
   touch_start(integer total_number)
   {
       key id = llDetectedKey(0);
       if (id == owner)
       {
           if (simGlobalCoords == ZERO_VECTOR)
           {
               llOwnerSay("Config error, tp request was denied. Please try again!");
               llResetScript();
           }
           else
           {
               llOwnerSay("Teleporting you to: http://maps.secondlife.com/secondlife/"
                   + llEscapeURL(simName) + "/" + (string)llRound(landingPoint.x)
                   + "/" + (string)llRound(landingPoint.y) + "/" + (string)llRound(landingPoint.z) + "/");
               llTeleportAgentGlobalCoords(owner, simGlobalCoords, landingPoint, ZERO_VECTOR);
           }
       }
       else
       {
           // llRegionSayTo is faster than llInstantMessage and we can assume
           // that the touching avatar is within the same sim
           llRegionSayTo(id, PUBLIC_CHANNEL,
               "Sorry, I can't tp you. You're NOT my owner!");
       }
   }
   run_time_permissions(integer perm)
   {
       // if permission request has been denied (read ! as not)
       if (!(perm & PERMISSION_TELEPORT))
       {
           llOwnerSay("I need permissions to teleport you!");
           llRequestPermissions(owner, PERMISSION_TELEPORT);
       }
   }

// dataserver event only called if data is returned // or in other words, if you request data for a sim that does // not exist this event will NOT be called

   dataserver(key query_id, string data)
   {
       simGlobalCoords = (vector)data;
       // llOwnerSay("Sim global coords: " + (string)simGlobalCoords);
   }

}

</lsl>

See Also

Events

•  run_time_permissions Permission receiving event

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llRequestSimulatorData Useful for requesting simulator position
•  llTeleportAgent Teleporting agents to a landmark or position in the region.

Articles

•  Script permissions

Deep Notes

Search JIRA for related Issues

Signature

function void llTeleportAgentGlobalCoords( key agent, vector global_coordinates, vector region_coordinates, vector look_at );