corrade-lsl-templates – Diff between revs 29 and 31
?pathlinks?
Rev 29 | Rev 31 | |||
---|---|---|---|---|
Line 180... | Line 180... | |||
180 | |
180 | |
|
181 | state teleport { |
181 | state teleport { |
|
182 | state_entry() { |
182 | state_entry() { |
|
183 | // DEBUG |
183 | // DEBUG |
|
- | 184 | llOwnerSay("Teleporting..."); |
||
- | 185 | |
||
- | 186 | /* |
||
- | 187 | * These calculations achieve the following: |
||
- | 188 | * - teleport Corrade in front of you at a distance the size of your bounding box, |
||
- | 189 | * - make Corrade turn towards 1m in front of its position after the teleport |
||
- | 190 | * The reason for doing this is that radar object detection is dependent on the |
||
- | 191 | * position that Corrade is facing. |
||
- | 192 | */ |
||
- | 193 | |
||
- | 194 | // Get the avatar global position and rotation. |
||
- | 195 | list details = llGetObjectDetails(llGetOwner(), [OBJECT_POS, OBJECT_ROT]); |
||
- | 196 | |
||
- | 197 | // Extract the position and rotation. |
||
- | 198 | vector pos = llList2Vector(details, 0); |
||
- | 199 | quaternion rot = llList2Rot(details, 1); |
||
- | 200 | // Compute the scale of the avatar (side of cuboid). |
||
- | 201 | list box = llGetBoundingBox(llGetOwner()); |
||
- | 202 | vector a = llList2Vector(box, 0); |
||
- | 203 | vector b = llList2Vector(box, 1); |
||
- | 204 | float size = b.x - a.x; |
||
- | 205 | |
||
- | 206 | vector position = <size, 0, 0> * rot + llGetPos(); |
||
- | 207 | vector lookAt = (<1, 0, 0> + <size, 0, 0>) * rot + llGetPos(); |
||
184 | llOwnerSay("Teleporting..."); |
208 | |
|
185 | llInstantMessage( |
209 | llInstantMessage( |
|
186 | (key)wasKeyValueGet( |
210 | (key)wasKeyValueGet( |
|
187 | "corrade", |
211 | "corrade", |
|
188 | configuration |
212 | configuration |
|
189 | ), |
213 | ), |
|
190 | wasKeyValueEncode( |
214 | wasKeyValueEncode( |
|
191 | [ |
215 | [ |
|
192 | "command", "teleport", |
216 | "command", "teleport", |
|
193 | "group", wasURLEscape( |
217 | "group", wasURLEscape( |
|
194 | wasKeyValueGet( |
218 | wasKeyValueGet( |
|
195 | "group", |
219 | "group", |
|
196 | configuration |
220 | configuration |
|
197 | ) |
221 | ) |
|
198 | ), |
222 | ), |
|
199 | "password", wasURLEscape( |
223 | "password", wasURLEscape( |
|
Line 205... | Line 229... | |||
205 | "entity", "region", |
229 | "entity", "region", |
|
206 | "region", wasURLEscape( |
230 | "region", wasURLEscape( |
|
207 | llGetRegionName() |
231 | llGetRegionName() |
|
208 | ), |
232 | ), |
|
209 | "deanimate", "True", |
233 | "deanimate", "True", |
|
210 | "position", llGetPos(), |
234 | "position", wasURLEscape((string)position), |
|
- | 235 | "turnto", wasURLEscape((string)lookAt), |
||
211 | "callback", wasURLEscape(callback) |
236 | "callback", wasURLEscape(callback) |
|
212 | ] |
237 | ] |
|
213 | ) |
238 | ) |
|
214 | ); |
239 | ); |
|
- | 240 | |
||
215 | llSetTimerEvent(60); |
241 | llSetTimerEvent(60); |
|
216 | } |
242 | } |
|
217 | timer() { |
243 | timer() { |
|
218 | // DEBUG |
244 | // DEBUG |
|
219 | llOwnerSay("Teleport failed..."); |
245 | llOwnerSay("Teleport failed..."); |
|
Line 230... | Line 256... | |||
230 | wasKeyValueGet("success", body) != "True") { |
256 | wasKeyValueGet("success", body) != "True") { |
|
231 | // DEBUG |
257 | // DEBUG |
|
232 | llOwnerSay("Teleport failed with failure message: " + |
258 | llOwnerSay("Teleport failed with failure message: " + |
|
233 | wasURLUnescape( |
259 | wasURLUnescape( |
|
234 | wasKeyValueGet( |
260 | wasKeyValueGet( |
|
235 | "error", |
261 | "data", |
|
236 | body |
262 | body |
|
237 | ) |
263 | ) |
|
238 | ) |
264 | ) |
|
239 | ); |
265 | ); |
|
240 | llSetColor(<.5,0,0>, ALL_SIDES); |
266 | llSetColor(<.5,0,0>, ALL_SIDES); |