corrade-lsl-templates – Diff between revs 29 and 37
?pathlinks?
Rev 29 | Rev 37 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 // |
2 | // Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 // |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // |
4 | // |
|
5 | // This is an automatic teleporter, and patrol script for the Corrade |
5 | // This is an automatic teleporter, and patrol script for the Corrade |
|
6 | // Second Life / OpenSim bot. You can find more details about the bot |
6 | // Second Life / OpenSim bot. You can find more details about the bot |
|
7 | // by following the URL: http://was.fm/secondlife/scripted_agents/corrade |
7 | // by following the URL: http://was.fm/secondlife/scripted_agents/corrade |
|
8 | // |
8 | // |
|
9 | // The purpose of this script is to demonstrate patroling with Corrade and |
9 | // The purpose of this script is to demonstrate patroling with Corrade and |
|
10 | // you are free to use, change, and commercialize it under the CC BY 2.0 |
10 | // you are free to use, change, and commercialize it under the GNU/GPLv3 |
|
11 | // license which can be found at: https://creativecommons.org/licenses/by/2.0 |
11 | // license which can be found at: http://www.gnu.org/licenses/gpl.html |
|
12 | // |
12 | // |
|
13 | /////////////////////////////////////////////////////////////////////////// |
13 | /////////////////////////////////////////////////////////////////////////// |
|
Line 14... | Line 14... | |||
14 | |
14 | |
|
15 | /////////////////////////////////////////////////////////////////////////// |
15 | /////////////////////////////////////////////////////////////////////////// |
|
16 | // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // |
16 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
17 | /////////////////////////////////////////////////////////////////////////// |
17 | /////////////////////////////////////////////////////////////////////////// |
|
18 | string wasKeyValueGet(string k, string data) { |
18 | string wasKeyValueGet(string k, string data) { |
|
19 | if(llStringLength(data) == 0) return ""; |
19 | if(llStringLength(data) == 0) return ""; |
|
20 | if(llStringLength(k) == 0) return ""; |
20 | if(llStringLength(k) == 0) return ""; |
|
Line 23... | Line 23... | |||
23 | if(i != -1) return llList2String(a, i+1); |
23 | if(i != -1) return llList2String(a, i+1); |
|
24 | return ""; |
24 | return ""; |
|
25 | } |
25 | } |
|
Line 26... | Line 26... | |||
26 | |
26 | |
|
27 | /////////////////////////////////////////////////////////////////////////// |
27 | /////////////////////////////////////////////////////////////////////////// |
|
28 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
28 | // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // |
|
29 | /////////////////////////////////////////////////////////////////////////// |
29 | /////////////////////////////////////////////////////////////////////////// |
|
30 | string wasKeyValueEncode(list data) { |
30 | string wasKeyValueEncode(list data) { |
|
31 | list k = llList2ListStrided(data, 0, -1, 2); |
31 | list k = llList2ListStrided(data, 0, -1, 2); |
|
32 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
32 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
|
Line 38... | Line 38... | |||
38 | } while(llGetListLength(k) != 0); |
38 | } while(llGetListLength(k) != 0); |
|
39 | return llDumpList2String(data, "&"); |
39 | return llDumpList2String(data, "&"); |
|
40 | } |
40 | } |
|
Line 41... | Line 41... | |||
41 | |
41 | |
|
42 | /////////////////////////////////////////////////////////////////////////// |
42 | /////////////////////////////////////////////////////////////////////////// |
|
43 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
43 | // Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
|
44 | /////////////////////////////////////////////////////////////////////////// |
44 | /////////////////////////////////////////////////////////////////////////// |
|
45 | // http://was.fm/secondlife/wanderer |
45 | // http://was.fm/secondlife/wanderer |
|
46 | vector wasCirclePoint(float radius) { |
46 | vector wasCirclePoint(float radius) { |
|
47 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
47 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
Line 50... | Line 50... | |||
50 | return <x, y, 0>; |
50 | return <x, y, 0>; |
|
51 | return wasCirclePoint(radius); |
51 | return wasCirclePoint(radius); |
|
52 | } |
52 | } |
|
Line 53... | Line 53... | |||
53 | |
53 | |
|
54 | /////////////////////////////////////////////////////////////////////////// |
54 | /////////////////////////////////////////////////////////////////////////// |
|
55 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
55 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
|
56 | /////////////////////////////////////////////////////////////////////////// |
56 | /////////////////////////////////////////////////////////////////////////// |
|
57 | // escapes a string in conformance with RFC1738 |
57 | // escapes a string in conformance with RFC1738 |
|
58 | string wasURLEscape(string i) { |
58 | string wasURLEscape(string i) { |
|
59 | string o = ""; |
59 | string o = ""; |
|
Line 321... | Line 321... | |||
321 | llOwnerSay("Corrade is not online, sleeping..."); |
321 | llOwnerSay("Corrade is not online, sleeping..."); |
|
322 | llResetScript(); |
322 | llResetScript(); |
|
323 | return; |
323 | return; |
|
324 | } |
324 | } |
|
325 | // DEBUG |
325 | // DEBUG |
|
326 | //llOwnerSay("Sending stop..."); |
- | ||
327 | llInstantMessage(CORRADE, |
- | ||
328 | wasKeyValueEncode( |
- | ||
329 | [ |
- | ||
330 | "command", "autopilot", |
- | ||
331 | "group", wasURLEscape(GROUP), |
- | ||
332 | "password", wasURLEscape(PASSWORD), |
- | ||
333 | "action", "stop", |
- | ||
334 | "callback", wasURLEscape(callback) |
- | ||
335 | ] |
- | ||
336 | ) |
- | ||
337 | ); |
- | ||
338 | } |
- | ||
339 | http_request(key id, string method, string body) { |
- | ||
340 | llHTTPResponse(id, 200, "OK"); |
- | ||
341 | if(wasKeyValueGet("command", body) != "autopilot" || |
- | ||
342 | wasKeyValueGet("success", body) != "True") { |
- | ||
343 | // DEBUG |
- | ||
344 | llOwnerSay("Could not get Corrade to stop, restarting script..."); |
- | ||
345 | llResetScript(); |
- | ||
346 | } |
- | ||
347 | // DEBUG |
- | ||
348 | //llOwnerSay("Sending next move..."); |
326 | //llOwnerSay("Sending next move..."); |
|
- | 327 | float timeout = 1 + llFrand(WAIT); |
||
349 | llInstantMessage(CORRADE, |
328 | llInstantMessage(CORRADE, |
|
350 | wasKeyValueEncode( |
329 | wasKeyValueEncode( |
|
351 | [ |
330 | [ |
|
352 | "command", "autopilot", |
331 | "command", "walkto", |
|
353 | "group", wasURLEscape(GROUP), |
332 | "group", wasURLEscape(GROUP), |
|
354 | "password", wasURLEscape(PASSWORD), |
333 | "password", wasURLEscape(PASSWORD), |
|
355 | "position", wasURLEscape( |
334 | "position", wasURLEscape( |
|
356 | (string)( |
335 | (string)( |
|
357 | llGetPos() + wasCirclePoint(RADIUS) |
336 | llGetPos() + wasCirclePoint(RADIUS) |
|
358 | ) |
337 | ) |
|
359 | ), |
338 | ), |
|
360 | "action", "start" |
339 | "vicinity", "1", |
|
- | 340 | "timeout", timeout |
||
361 | ] |
341 | ] |
|
362 | ) |
342 | ) |
|
363 | ); |
343 | ); |
|
364 | llSetTimerEvent(1 + llFrand(WAIT)); |
344 | llSetTimerEvent(timeout); |
|
365 | } |
345 | } |
|
366 | on_rez(integer num) { |
346 | on_rez(integer num) { |
|
367 | llResetScript(); |
347 | llResetScript(); |
|
368 | } |
348 | } |
|
369 | changed(integer change) { |
349 | changed(integer change) { |