LlTeleportAgentGlobalCoords
Looking for the current API? Open the llTeleportAgentGlobalCoords reference →
Wiki description
Teleports an
agent to region_coordinates within a region specified by global_coordinates.A region's global coordinates can be retrieved using
llRequestSimulatorData("region name", DATA_SIM_POS)If the destination is in the current region, the avatar will land facing
look_at as a position within that region. Otherwise, look_at is treated as a unit direction.Function notes
The combination of llRequestSimulatorData and llTeleportAgentGlobalCoords allows agents to be teleported to regions by region name.
Caveats
- This function can only teleport the owner of the object (unless part of an Experience).
- Teleports are throttled
- This function cannot be used in a script in an object attached using llAttachToAvatarTemp.
- Sitting avatars cannot be teleported using this function. You must llUnSit them first.
- This function does not override a parcel's teleport settings, i.e. if the parcel has a landing zone enabled the avatar will be teleported there.
- If the script is part of an experience that the avatar has granted permission, then this function may teleport them without being the owner and it will override parcel teleport routing.
- When
look_attreated treated as a direction, a valid input should be<llCos(angle), llSin(angle), 0.0>.- In other words, it should be a unit vector corresponding to the avatar turning angle radians from north.
Examples
Basic example:
default
{
touch_start(integer num_detected)
{
llRequestPermissions(llGetOwner(), PERMISSION_TELEPORT);
}
run_time_permissions(integer perm)
{
if (PERMISSION_TELEPORT & perm)
{
vector global_coord = <232704, 291072, 0>;
vector region_pos = <122, 122, 40>;
llTeleportAgentGlobalCoords(llGetPermissionsKey(), global_coord, region_pos, ZERO_VECTOR);
}
}
}Similar to the above, but also keeps track of current global coordinate and adjusts the look_at value based on whether the destination is the current region or a different one. This ensures that the avatar will always be facing the same direction regardless of whether they're teleporting within the region or to another one.
The script keeps track of the current region's global coordinate in state_entry and changed events, which is later used to check whether the destination has the same global coordinates.
vector current_region;
default
{
state_entry()
{
// Get current global coordinate when the script starts.
llRequestSimulatorData(llGetRegionName(), DATA_SIM_POS);
}
changed(integer change)
{
if (!(change & CHANGED_REGION)) return;
// Get current region coordinate when entering a new region.
llRequestSimulatorData(llGetRegionName(), DATA_SIM_POS);
}
dataserver(key query, string data)
{
// Save llRequestSimulatorData response.
current_region = (vector)data;
}
touch_start(integer num_detected)
{
llRequestPermissions(llGetOwner(), PERMISSION_TELEPORT);
}
run_time_permissions(integer perm)
{
if (!(PERMISSION_TELEPORT & perm)) return;
vector global_coord = <232704, 291072, 0>;
vector region_pos = <122, 122, 40>;
float angle = 45 * DEG_TO_RAD;
vector look_at = <llCos(angle), llSin(angle), 0>;
if (current_region == global_coord) {
// When teleporting within the current region, we should use a position within the region instead.
look_at = region_pos + look_at;
}
llTeleportAgentGlobalCoords(llGetPermissionsKey(), global_coord, region_pos, look_at);
}
}Older example:
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);
}
}See also: functions
History
Date of Release 24/07/2012
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{#if:
{{#vardefine:p_{{{1|none}}}_desc|avatar {{#if:{{{group|}}}|or group}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}{{{region|}}}|that is in the same [[region]] {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region{{Footnote|handle=known}}}}}}}}
{{#vardefine:p_{{{1|none}}}_hover|avatar {{#if:{{{group|}}}|or group}} UUID {{#if:{{{sim|}}}{{{region|}}}|that is in the same region {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region}}}}}}
<includeonly>
{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{LSLC|Avatar/As A Parameter||{{#var:lang}}}}}}
}}}}
</includeonly>
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|p_{{{1|none}}}_desc}}
|-
{{VarPair|p_{{{1|none}}}_hover}}
|}
</noinclude>Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|BUG-4062|[[llTeleportAgent]]() and [[llTeleportAgentGlobalCoords]]() can break any script in any [[attachment|attached]] object that contains a [[changed]] event.|type=bug|resolution=fixed}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-7987|llTeleportAgent always points in the positive Y direction on teleport|type=bug|resolution=wont}}Template:LSL Function/position
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>
This template is to be used to specify setup the description for position like parameters (offsets, positions, points, etc.).
Right now it's pretty basic and easy to edit. I'm wondering if these functions should be in a position parameter specific category.
====TODO====
* add clamping flag and verbiage for out of region/range coordinates.
</noinclude>{{#if:
{{#if:{{{region|}}}|
{{#if:{{{local|}}}|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region}} or [[Viewer coordinate frames#Local|local coordinates]] depending upon the situation{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region or local coordinates depending upon the situation{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#ifeq:{{{1|}}}|point|
{{#vardefine:p_{{{1|}}}_desc|A point in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region-local}} space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|A point in region-local space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region coordinates}}{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region coordinates{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
|
{{#if:{{{local|}}}|
{{#ifeq:{{{1|}}}|offset|
{{LSL Function/offset|{{{1|}}}|local={{{local}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in [[Viewer coordinate frames#Local|local coordinates]]{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in local coordinates{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
}}
}}Original shared helper source (conditional wiki logic is not evaluated)
{{LSLPT|{{{1|}}}|{{{2|}}}|{{{3|}}}}}<noinclude>
Same exact syntax as [[Template:LSL Param]].
</noinclude>Template:LSL Function/permission
Original shared helper source (conditional wiki logic is not evaluated)
{{#if:
{{{{#if:{{#var:DEBUG_CHANNEL}}||:DEBUG_CHANNEL}}|}}
{{#vardefine:header_footnote|{{#var:header_footnote}}{{#if:{{{1|<noinclude>*</noinclude>}}}|To run this function the script must request the [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} permission with [[llRequestPermissions]]{{#ifeq:{{{grant|anyone}}}|anyone|| and it must be granted by {{{grant|anyone}}}}}.}}}}
{{#vardefine:caveats|{{#var:caveats}}{{#if:{{{1|<noinclude>*</noinclude>}}}|{{PBR}}
<div style="border: 1px dotted rgba(0,0,0,0.5);">{{Collapsible_Table/Simple|title=<h5 style="margin:0;">Permissions</h5>|table-style=width:100%;|autocollapse=*|content={{!}}<div>
* Do not depend upon the auto-grant status of permissions. '''Always''' use the [[run_time_permissions]] event.
* If the script lacks {{#if:{{{2|}}}|both the permissions [[{{{1}}}]] and [[{{{2}}}]]|the permission [[{{{1}}}]]}}, the script will shout an error on {{#var:DEBUG_CHANNEL}} and the operation fails (but the script continues to run).{{#ifeq:{{{grant|anyone<noinclude>*</noinclude>}}}|anyone||
* If [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} is granted by anyone other than {{{grant|anyone}}}, then when the function is called an error will be shouted on {{#var:DEBUG_CHANNEL}}.}}
{{{caveats|}}}{{LSL Function/permission/caveat switch|{{{1}}}}}{{#if:{{{2|}}}|{{LSL Function/permission/caveat switch|{{{2}}}}}}}</div>}}</div>}}}}
{{#vardefine:also_events|{{#var:also_events}}
{{LSL DefineRow||[[run_time_permissions]]|Permission receiving event}}}}
{{#vardefine:also_functions|{{#var:also_functions}}
{{LSL DefineRow||[[llGetPermissions]]|Get the permissions granted}}
{{LSL DefineRow||[[llGetPermissionsKey]]|Get the agent who granted permissions}}
{{LSL DefineRow||[[llRequestPermissions]]|Request permissions}}}}
{{#vardefine:also_articles|{{#var:also_articles}}
{{LSL DefineRow||[[:Category:LSL Permissions/Script|Script permissions]]|}}}}
<includeonly>{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||[[Category:LSL Requires Permissions]]}}
}}}}</includeonly>
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|header_footnote}}
|-
{{VarPair|caveats}}
|-
{{VarPairTable|also_events}}
|-
{{VarPairTable|also_functions}}
|-
{{VarPairTable|also_articles}}
|}
</noinclude>Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.