/source/heads-up-display/teleport/teleport.lsl |
@@ -182,6 +182,30 @@ |
state_entry() { |
// DEBUG |
llOwnerSay("Teleporting..."); |
|
/* |
* These calculations achieve the following: |
* - teleport Corrade in front of you at a distance the size of your bounding box, |
* - make Corrade turn towards 1m in front of its position after the teleport |
* The reason for doing this is that radar object detection is dependent on the |
* position that Corrade is facing. |
*/ |
|
// Get the avatar global position and rotation. |
list details = llGetObjectDetails(llGetOwner(), [OBJECT_POS, OBJECT_ROT]); |
|
// Extract the position and rotation. |
vector pos = llList2Vector(details, 0); |
quaternion rot = llList2Rot(details, 1); |
// Compute the scale of the avatar (side of cuboid). |
list box = llGetBoundingBox(llGetOwner()); |
vector a = llList2Vector(box, 0); |
vector b = llList2Vector(box, 1); |
float size = b.x - a.x; |
|
vector position = <size, 0, 0> * rot + llGetPos(); |
vector lookAt = (<1, 0, 0> + <size, 0, 0>) * rot + llGetPos(); |
|
llInstantMessage( |
(key)wasKeyValueGet( |
"corrade", |
@@ -207,11 +231,13 @@ |
llGetRegionName() |
), |
"deanimate", "True", |
"position", llGetPos(), |
"position", wasURLEscape((string)position), |
"turnto", wasURLEscape((string)lookAt), |
"callback", wasURLEscape(callback) |
] |
) |
); |
|
llSetTimerEvent(60); |
} |
timer() { |
@@ -232,7 +258,7 @@ |
llOwnerSay("Teleport failed with failure message: " + |
wasURLUnescape( |
wasKeyValueGet( |
"error", |
"data", |
body |
) |
) |