corrade-lsl-templates – Diff between revs 32 and 36

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 32 Rev 36
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 // 2 // Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 //
3 /////////////////////////////////////////////////////////////////////////// 3 ///////////////////////////////////////////////////////////////////////////
4 // 4 //
5 // This is an automatic grid follower for the Corrade Second Life / OpenSim 5 // This is an automatic grid follower for the Corrade Second Life / OpenSim
6 // bot. It uses two different engines: the simulator's built-in autopilot 6 // bot. It uses two different engines: the simulator's built-in autopilot
7 // and a fly engine that will make Corrade fly to your location. 7 // and a fly engine that will make Corrade fly to your location.
8 // You can find more details about the bot by following the URL: 8 // You can find more details about the bot by following the URL:
9 // http://grimore.org/secondlife/scripted_agents/corrade 9 // http://grimore.org/secondlife/scripted_agents/corrade
10 // 10 //
11 // The follower script works together with a "configuration" notecard and 11 // The follower script works together with a "configuration" notecard and
12 // that must be placed in the same primitive as this script. 12 // that must be placed in the same primitive as this script.
13 // You are free to use, change, and commercialize it under the CC BY 2.0 13 // You are free to use, change, and commercialize it under the CC BY 2.0
14 // license at: https://creativecommons.org/licenses/by/2.0 14 // license at: https://creativecommons.org/licenses/by/2.0
15 // 15 //
16 /////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////
17   17  
18 /////////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////////
19 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // 19 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
20 /////////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////////
21 string wasKeyValueGet(string k, string data) { 21 string wasKeyValueGet(string k, string data) {
22 if(llStringLength(data) == 0) return ""; 22 if(llStringLength(data) == 0) return "";
23 if(llStringLength(k) == 0) return ""; 23 if(llStringLength(k) == 0) return "";
24 list a = llParseString2List(data, ["&", "="], []); 24 list a = llParseString2List(data, ["&", "="], []);
25 integer i = llListFindList(a, [ k ]); 25 integer i = llListFindList(a, [ k ]);
26 if(i != -1) return llList2String(a, i+1); 26 if(i != -1) return llList2String(a, i+1);
27 return ""; 27 return "";
28 } 28 }
29 29
30 /////////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////////
31 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 31 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
32 /////////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////////
33 string wasKeyValueEncode(list data) { 33 string wasKeyValueEncode(list data) {
34 list k = llList2ListStrided(data, 0, -1, 2); 34 list k = llList2ListStrided(data, 0, -1, 2);
35 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); 35 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2);
36 data = []; 36 data = [];
37 do { 37 do {
38 data += llList2String(k, 0) + "=" + llList2String(v, 0); 38 data += llList2String(k, 0) + "=" + llList2String(v, 0);
39 k = llDeleteSubList(k, 0, 0); 39 k = llDeleteSubList(k, 0, 0);
40 v = llDeleteSubList(v, 0, 0); 40 v = llDeleteSubList(v, 0, 0);
41 } while(llGetListLength(k) != 0); 41 } while(llGetListLength(k) != 0);
42 return llDumpList2String(data, "&"); 42 return llDumpList2String(data, "&");
43 } 43 }
44   44  
45 /////////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////////
46 // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // 46 // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
47 /////////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////////
48 vector wasCirclePoint(float radius) { 48 vector wasCirclePoint(float radius) {
49 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 49 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
50 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 50 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
51 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) 51 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2))
52 return <x, y, 0>; 52 return <x, y, 0>;
53 return wasCirclePoint(radius); 53 return wasCirclePoint(radius);
54 } 54 }
55   55  
56 /////////////////////////////////////////////////////////////////////////// 56 ///////////////////////////////////////////////////////////////////////////
57 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // 57 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
58 /////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////
59 integer wasIsAvatarInSensorRange(key avatar) { 59 integer wasIsAvatarInSensorRange(key avatar) {
60 return llListFindList( 60 return llListFindList(
61 llGetAgentList( 61 llGetAgentList(
62 AGENT_LIST_REGION, 62 AGENT_LIST_REGION,
63 [] 63 []
64 ), 64 ),
65 (list)((key)avatar) 65 (list)((key)avatar)
66 ) != -1 && 66 ) != -1 &&
67 llVecDist( 67 llVecDist(
68 llGetPos(), 68 llGetPos(),
69 llList2Vector( 69 llList2Vector(
70 llGetObjectDetails( 70 llGetObjectDetails(
71 avatar, 71 avatar,
72 [OBJECT_POS] 72 [OBJECT_POS]
73 ), 73 ),
74 0 74 0
75 ) 75 )
76 ) <= 96; 76 ) <= 96;
77 } 77 }
78   78  
79 /////////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////////
80 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 80 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
81 /////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////
82 // escapes a string in conformance with RFC1738 82 // escapes a string in conformance with RFC1738
83 string wasURLEscape(string i) { 83 string wasURLEscape(string i) {
84 string o = ""; 84 string o = "";
85 do { 85 do {
86 string c = llGetSubString(i, 0, 0); 86 string c = llGetSubString(i, 0, 0);
87 i = llDeleteSubString(i, 0, 0); 87 i = llDeleteSubString(i, 0, 0);
88 if(c == "") jump continue; 88 if(c == "") jump continue;
89 if(c == " ") { 89 if(c == " ") {
90 o += "+"; 90 o += "+";
91 jump continue; 91 jump continue;
92 } 92 }
93 if(c == "\n") { 93 if(c == "\n") {
94 o += "%0D" + llEscapeURL(c); 94 o += "%0D" + llEscapeURL(c);
95 jump continue; 95 jump continue;
96 } 96 }
97 o += llEscapeURL(c); 97 o += llEscapeURL(c);
98 @continue; 98 @continue;
99 } while(i != ""); 99 } while(i != "");
100 return o; 100 return o;
101 } 101 }
102   102  
103 // for holding the callback URL 103 // for holding the callback URL
104 string callback = ""; 104 string callback = "";
105   105  
106 // key-value data will be read into this list 106 // key-value data will be read into this list
107 string configuration = ""; 107 string configuration = "";
108 108
109 default { 109 default {
110 state_entry() { 110 state_entry() {
111 llSetTimerEvent(1); 111 llSetTimerEvent(1);
112 } 112 }
113 link_message(integer sender, integer num, string message, key id) { 113 link_message(integer sender, integer num, string message, key id) {
114 if(sender != 1 || id != "configuration") return; 114 if(sender != 1 || id != "configuration") return;
115 configuration = message; 115 configuration = message;
116 state off; 116 state off;
117 } 117 }
118 timer() { 118 timer() {
119 llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY); 119 llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY);
120 } 120 }
121 attach(key id) { 121 attach(key id) {
122 llResetScript(); 122 llResetScript();
123 } 123 }
124 on_rez(integer num) { 124 on_rez(integer num) {
125 llResetScript(); 125 llResetScript();
126 } 126 }
127 changed(integer change) { 127 changed(integer change) {
128 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 128 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
129 llResetScript(); 129 llResetScript();
130 if( 130 if(
131 (change & CHANGED_REGION_START) || 131 (change & CHANGED_REGION_START) ||
132 (change & CHANGED_REGION)) { 132 (change & CHANGED_REGION)) {
133 state on; 133 state on;
134 } 134 }
135 } 135 }
136 state_exit() { 136 state_exit() {
137 llSetTimerEvent(0); 137 llSetTimerEvent(0);
138 } 138 }
139 } 139 }
140   140  
141 state off { 141 state off {
142 state_entry() { 142 state_entry() {
143 llSetColor(<.5,0,0>, ALL_SIDES); 143 llSetColor(<.5,0,0>, ALL_SIDES);
144 } 144 }
145 touch_end(integer num) { 145 touch_end(integer num) {
146 state on; 146 state on;
147 } 147 }
148 attach(key id) { 148 attach(key id) {
149 llResetScript(); 149 llResetScript();
150 } 150 }
151 on_rez(integer num) { 151 on_rez(integer num) {
152 llResetScript(); 152 llResetScript();
153 } 153 }
154 changed(integer change) { 154 changed(integer change) {
155 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 155 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
156 llResetScript(); 156 llResetScript();
157 } 157 }
158 } 158 }
159   159  
160 state on { 160 state on {
161 state_entry() { 161 state_entry() {
162 llSetColor(<0,.5,0>, ALL_SIDES); 162 llSetColor(<0,.5,0>, ALL_SIDES);
163 state url; 163 state url;
164 } 164 }
165 attach(key id) { 165 attach(key id) {
166 llResetScript(); 166 llResetScript();
167 } 167 }
168 on_rez(integer num) { 168 on_rez(integer num) {
169 llResetScript(); 169 llResetScript();
170 } 170 }
171 changed(integer change) { 171 changed(integer change) {
172 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 172 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
173 llResetScript(); 173 llResetScript();
174 } 174 }
175 } 175 }
176 176
177 state url { 177 state url {
178 state_entry() { 178 state_entry() {
179 // DEBUG 179 // DEBUG
180 llOwnerSay("Requesting URL..."); 180 llOwnerSay("Requesting URL...");
181 llRequestURL(); 181 llRequestURL();
182 } 182 }
183 touch_end(integer num) { 183 touch_end(integer num) {
184 llSetColor(<.5,0,0>, ALL_SIDES); 184 llSetColor(<.5,0,0>, ALL_SIDES);
185 llResetScript(); 185 llResetScript();
186 } 186 }
187 http_request(key id, string method, string body) { 187 http_request(key id, string method, string body) {
188 if(method != URL_REQUEST_GRANTED) return; 188 if(method != URL_REQUEST_GRANTED) return;
189 callback = body; 189 callback = body;
190 // DEBUG 190 // DEBUG
191 llOwnerSay("Got URL..."); 191 llOwnerSay("Got URL...");
192 state detect; 192 state detect;
193 } 193 }
194 attach(key id) { 194 attach(key id) {
195 llResetScript(); 195 llResetScript();
196 } 196 }
197 on_rez(integer num) { 197 on_rez(integer num) {
198 llResetScript(); 198 llResetScript();
199 } 199 }
200 changed(integer change) { 200 changed(integer change) {
201 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 201 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
202 llResetScript(); 202 llResetScript();
203 if( 203 if(
204 (change & CHANGED_REGION_START) || 204 (change & CHANGED_REGION_START) ||
205 (change & CHANGED_REGION)) { 205 (change & CHANGED_REGION)) {
206 state on; 206 state on;
207 } 207 }
208 } 208 }
209 } 209 }
210 210
211 state detect { 211 state detect {
212 state_entry() { 212 state_entry() {
213 // set color for button 213 // set color for button
214 llSetColor(<0,.5,0>, ALL_SIDES); 214 llSetColor(<0,.5,0>, ALL_SIDES);
215 // if Corrade is in-range then just follow 215 // if Corrade is in-range then just follow
216 if(wasIsAvatarInSensorRange( 216 if(wasIsAvatarInSensorRange(
217 (key)wasKeyValueGet( 217 (key)wasKeyValueGet(
218 "corrade", 218 "corrade",
219 configuration 219 configuration
220 ) 220 )
221 ) 221 )
222 ) state select; 222 ) state select;
223 // DEBUG 223 // DEBUG
224 llOwnerSay("Detecting if Corrade is online..."); 224 llOwnerSay("Detecting if Corrade is online...");
225 llRequestAgentData( 225 llRequestAgentData(
226 (key)wasKeyValueGet( 226 (key)wasKeyValueGet(
227 "corrade", 227 "corrade",
228 configuration 228 configuration
229 ), 229 ),
230 DATA_ONLINE 230 DATA_ONLINE
231 ); 231 );
232 } 232 }
233 touch_end(integer num) { 233 touch_end(integer num) {
234 llSetColor(<.5,0,0>, ALL_SIDES); 234 llSetColor(<.5,0,0>, ALL_SIDES);
235 llResetScript(); 235 llResetScript();
236 } 236 }
237 dataserver(key id, string data) { 237 dataserver(key id, string data) {
238 if(data != "1") { 238 if(data != "1") {
239 // DEBUG 239 // DEBUG
240 llOwnerSay("Corrade is not online, sleeping..."); 240 llOwnerSay("Corrade is not online, sleeping...");
241 llResetScript(); 241 llResetScript();
242 return; 242 return;
243 } 243 }
244 llSensorRepeat("", 244 llSensorRepeat("",
245 (key)wasKeyValueGet( 245 (key)wasKeyValueGet(
246 "corrade", 246 "corrade",
247 configuration 247 configuration
248 ), 248 ),
249 AGENT, 249 AGENT,
250 (integer)wasURLEscape( 250 (integer)wasURLEscape(
251 wasKeyValueGet( 251 wasKeyValueGet(
252 "range", 252 "range",
253 configuration 253 configuration
254 ) 254 )
255 ), 255 ),
256 TWO_PI, 256 TWO_PI,
257 5 257 5
258 ); 258 );
259 } 259 }
260 no_sensor() { 260 no_sensor() {
261 // DEBUG 261 // DEBUG
262 llOwnerSay("Teleporting Corrade..."); 262 llOwnerSay("Teleporting Corrade...");
263 llInstantMessage( 263 llInstantMessage(
264 (key)wasKeyValueGet( 264 (key)wasKeyValueGet(
265 "corrade", 265 "corrade",
266 configuration 266 configuration
267 ), 267 ),
268 wasKeyValueEncode( 268 wasKeyValueEncode(
269 [ 269 [
270 "command", "teleport", 270 "command", "teleport",
271 "group", wasURLEscape( 271 "group", wasURLEscape(
272 wasKeyValueGet( 272 wasKeyValueGet(
273 "group", 273 "group",
274 configuration 274 configuration
275 ) 275 )
276 ), 276 ),
277 "password", wasURLEscape( 277 "password", wasURLEscape(
278 wasKeyValueGet( 278 wasKeyValueGet(
279 "password", 279 "password",
280 configuration 280 configuration
281 ) 281 )
282 ), 282 ),
283 "entity", "region", 283 "entity", "region",
284 "region", wasURLEscape(llGetRegionName()), 284 "region", wasURLEscape(llGetRegionName()),
285 "position", llGetPos() + wasCirclePoint( 285 "position", llGetPos() + wasCirclePoint(
286 (integer)wasURLEscape( 286 (integer)wasURLEscape(
287 wasKeyValueGet( 287 wasKeyValueGet(
288 "range", 288 "range",
289 configuration 289 configuration
290 ) 290 )
291 ) 291 )
292 ), 292 ),
293 "deanimate", "True", 293 "deanimate", "True",
294 "callback", callback 294 "callback", callback
295 ] 295 ]
296 ) 296 )
297 ); 297 );
298 } 298 }
299 sensor(integer num) { 299 sensor(integer num) {
300 state select; 300 state select;
301 } 301 }
302 http_request(key id, string method, string body) { 302 http_request(key id, string method, string body) {
303 llHTTPResponse(id, 200, "OK"); 303 llHTTPResponse(id, 200, "OK");
304 if(wasKeyValueGet("command", body) != "teleport" || 304 if(wasKeyValueGet("command", body) != "teleport" ||
305 wasKeyValueGet("success", body) != "True") { 305 wasKeyValueGet("success", body) != "True") {
306 // DEBUG 306 // DEBUG
307 llOwnerSay("Teleport failed..."); 307 llOwnerSay("Teleport failed...");
308 return; 308 return;
309 } 309 }
310 state select; 310 state select;
311 } 311 }
312 attach(key id) { 312 attach(key id) {
313 llResetScript(); 313 llResetScript();
314 } 314 }
315 on_rez(integer num) { 315 on_rez(integer num) {
316 llResetScript(); 316 llResetScript();
317 } 317 }
318 changed(integer change) { 318 changed(integer change) {
319 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 319 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
320 llResetScript(); 320 llResetScript();
321 if( 321 if(
322 (change & CHANGED_REGION_START) || 322 (change & CHANGED_REGION_START) ||
323 (change & CHANGED_REGION)) { 323 (change & CHANGED_REGION)) {
324 state on; 324 state on;
325 } 325 }
326 } 326 }
327 } 327 }
328   328  
329 state select { 329 state select {
330 state_entry() { 330 state_entry() {
331 // DEBUG 331 // DEBUG
332 llOwnerSay("Selecting follow engine..."); 332 llOwnerSay("Selecting follow engine...");
333 llSetTimerEvent(1); 333 llSetTimerEvent(1);
334 } 334 }
335 touch_end(integer num) { 335 touch_end(integer num) {
336 llSetColor(<.5,0,0>, ALL_SIDES); 336 llSetColor(<.5,0,0>, ALL_SIDES);
337 llResetScript(); 337 llResetScript();
338 } 338 }
339 timer() { 339 timer() {
340 vector cPos = llList2Vector( 340 vector cPos = llList2Vector(
341 llGetObjectDetails( 341 llGetObjectDetails(
342 (key)wasKeyValueGet( 342 (key)wasKeyValueGet(
343 "corrade", 343 "corrade",
344 configuration 344 configuration
345 ), 345 ),
346 [OBJECT_POS] 346 [OBJECT_POS]
347 ), 347 ),
348 0 348 0
349 ); 349 );
350 vector mPos = llGetPos(); 350 vector mPos = llGetPos();
351 // If Corrade is in range then stop. 351 // If Corrade is in range then stop.
352 if(llVecDist(mPos, cPos) < 5) return; 352 if(llVecDist(mPos, cPos) < 5) return;
353 // If we are flying or the distance between us and Corrade 353 // If we are flying or the distance between us and Corrade
354 // is larger than a given distance then make Corrade fly. 354 // is larger than a given distance then make Corrade fly.
355 if( 355 if(
356 ( 356 (
357 llGetAgentInfo(llGetOwner()) & AGENT_FLYING 357 llGetAgentInfo(llGetOwner()) & AGENT_FLYING
358 ) || 358 ) ||
359 llFabs(mPos.z - cPos.z) > 5) { 359 llFabs(mPos.z - cPos.z) > 5) {
360 state stop_pilot; 360 state stop_pilot;
361 } 361 }
362 // Otherwise, stop flight and walk. 362 // Otherwise, stop flight and walk.
363 if(llGetAgentInfo( 363 if(llGetAgentInfo(
364 (key)wasKeyValueGet( 364 (key)wasKeyValueGet(
365 "corrade", 365 "corrade",
366 configuration 366 configuration
367 ) 367 )
368 ) & AGENT_FLYING) state stop_flight; 368 ) & AGENT_FLYING) state stop_flight;
369 // If Corrade is not flying then walk. 369 // If Corrade is not flying then walk.
370 state walk; 370 state walk;
371 } 371 }
372 attach(key id) { 372 attach(key id) {
373 llResetScript(); 373 llResetScript();
374 } 374 }
375 on_rez(integer num) { 375 on_rez(integer num) {
376 llResetScript(); 376 llResetScript();
377 } 377 }
378 changed(integer change) { 378 changed(integer change) {
379 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 379 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
380 llResetScript(); 380 llResetScript();
381 if( 381 if(
382 (change & CHANGED_REGION_START) || 382 (change & CHANGED_REGION_START) ||
383 (change & CHANGED_REGION)) { 383 (change & CHANGED_REGION)) {
384 state on; 384 state on;
385 } 385 }
386 } 386 }
387 state_exit() { 387 state_exit() {
388 llSetTimerEvent(0); 388 llSetTimerEvent(0);
389 } 389 }
390 } 390 }
391   391  
392 state stop_pilot { 392 state stop_pilot {
393 state_entry() { 393 state_entry() {
394 // DEBUG -  
395 llOwnerSay("Stopping autopilot for flight..."); -  
396 llRegionSayTo( -  
397 (key)wasKeyValueGet( -  
398 "corrade", -  
399 configuration -  
400 ), -  
401 0, -  
402 wasKeyValueEncode( -  
403 [ 394 state fly;
404 "command", "autopilot", -  
405 "group", wasURLEscape( -  
406 wasKeyValueGet( -  
407 "group", -  
408 configuration -  
409 ) -  
410 ), -  
411 "password", wasURLEscape( -  
412 wasKeyValueGet( -  
413 "password", -  
414 configuration -  
415 ) -  
416 ), -  
417 // move in a radius around the current primitive. -  
418 "position", llGetPos() + wasCirclePoint( -  
419 (integer)wasURLEscape( -  
420 wasKeyValueGet( -  
421 "range", -  
422 configuration -  
423 ) -  
424 ) -  
425 ), -  
426 "action", "stop", -  
427 "callback", wasURLEscape(callback) -  
428 ] -  
429 ) -  
430 ); -  
431 llSetTimerEvent(60); 395 llSetTimerEvent(60);
432 } 396 }
433 timer() { 397 timer() {
434 state on; 398 state on;
435 } 399 }
436 touch_end(integer num) { 400 touch_end(integer num) {
437 llSetColor(<.5,0,0>, ALL_SIDES); 401 llSetColor(<.5,0,0>, ALL_SIDES);
438 llResetScript(); 402 llResetScript();
439 } 403 }
440 http_request(key id, string method, string body) { -  
441 llHTTPResponse(id, 200, "OK"); -  
442 if(wasKeyValueGet("command", body) != "autopilot" || -  
443 wasKeyValueGet("success", body) != "True") { -  
444 // DEBUG -  
445 llOwnerSay("Failed to stop autopilot..."); -  
446 state on; -  
447 } -  
448 state fly; -  
449 } -  
450 attach(key id) { 404 attach(key id) {
451 llResetScript(); 405 llResetScript();
452 } 406 }
453 on_rez(integer num) { 407 on_rez(integer num) {
454 llResetScript(); 408 llResetScript();
455 } 409 }
456 changed(integer change) { 410 changed(integer change) {
457 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 411 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
458 llResetScript(); 412 llResetScript();
459 if( 413 if(
460 (change & CHANGED_REGION_START) || 414 (change & CHANGED_REGION_START) ||
461 (change & CHANGED_REGION)) { 415 (change & CHANGED_REGION)) {
462 state on; 416 state on;
463 } 417 }
464 } 418 }
465 state_exit() { 419 state_exit() {
466 llSetTimerEvent(0); 420 llSetTimerEvent(0);
467 } 421 }
468 } 422 }
469   423  
470 state fly { 424 state fly {
471 state_entry() { 425 state_entry() {
472 // DEBUG 426 // DEBUG
473 llOwnerSay("Flying to agent..."); 427 llOwnerSay("Flying to agent...");
474 llRegionSayTo( 428 llRegionSayTo(
475 (key)wasKeyValueGet( 429 (key)wasKeyValueGet(
476 "corrade", 430 "corrade",
477 configuration 431 configuration
478 ), 432 ),
479 0, 433 0,
480 wasKeyValueEncode( 434 wasKeyValueEncode(
481 [ 435 [
482 "command", "flyto", 436 "command", "flyto",
483 "group", wasURLEscape( 437 "group", wasURLEscape(
484 wasKeyValueGet( 438 wasKeyValueGet(
485 "group", 439 "group",
486 configuration 440 configuration
487 ) 441 )
488 ), 442 ),
489 "password", wasURLEscape( 443 "password", wasURLEscape(
490 wasKeyValueGet( 444 wasKeyValueGet(
491 "password", 445 "password",
492 configuration 446 configuration
493 ) 447 )
494 ), 448 ),
495 // move in a radius around the current primitive. 449 // move in a radius around the current primitive.
496 "position", llGetPos() + wasCirclePoint( 450 "position", llGetPos() + wasCirclePoint(
497 (integer)wasURLEscape( 451 (integer)wasURLEscape(
498 wasKeyValueGet( 452 wasKeyValueGet(
499 "range", 453 "range",
500 configuration 454 configuration
501 ) 455 )
502 ) 456 )
503 ), 457 ),
504 "fly", "True", 458 "fly", "True",
505 "vicinity", wasCirclePoint( 459 "vicinity", wasCirclePoint(
506 (integer)wasURLEscape( 460 (integer)wasURLEscape(
507 wasKeyValueGet( 461 wasKeyValueGet(
508 "range", 462 "range",
509 configuration 463 configuration
510 ) 464 )
511 ) 465 )
512 ), 466 ),
513 "duration", "2500", 467 "duration", "2500",
514 "callback", wasURLEscape(callback) 468 "callback", wasURLEscape(callback)
515 ] 469 ]
516 ) 470 )
517 ); 471 );
518 llSetTimerEvent(60); 472 llSetTimerEvent(60);
519 } 473 }
520 timer() { 474 timer() {
521 state on; 475 state on;
522 } 476 }
523 touch_end(integer num) { 477 touch_end(integer num) {
524 llSetColor(<.5,0,0>, ALL_SIDES); 478 llSetColor(<.5,0,0>, ALL_SIDES);
525 llResetScript(); 479 llResetScript();
526 } 480 }
527 http_request(key id, string method, string body) { 481 http_request(key id, string method, string body) {
528 llHTTPResponse(id, 200, "OK"); 482 llHTTPResponse(id, 200, "OK");
529 if(wasKeyValueGet("command", body) != "flyto" || 483 if(wasKeyValueGet("command", body) != "flyto" ||
530 wasKeyValueGet("success", body) != "True") { 484 wasKeyValueGet("success", body) != "True") {
531 // DEBUG 485 // DEBUG
532 llOwnerSay("Flight failed..."); 486 llOwnerSay("Flight failed...");
533 state on; 487 state on;
534 } 488 }
535 state select; 489 state select;
536 } 490 }
537 attach(key id) { 491 attach(key id) {
538 llResetScript(); 492 llResetScript();
539 } 493 }
540 on_rez(integer num) { 494 on_rez(integer num) {
541 llResetScript(); 495 llResetScript();
542 } 496 }
543 changed(integer change) { 497 changed(integer change) {
544 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 498 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
545 llResetScript(); 499 llResetScript();
546 if( 500 if(
547 (change & CHANGED_REGION_START) || 501 (change & CHANGED_REGION_START) ||
548 (change & CHANGED_REGION)) { 502 (change & CHANGED_REGION)) {
549 state on; 503 state on;
550 } 504 }
551 } 505 }
552 state_exit() { 506 state_exit() {
553 llSetTimerEvent(0); 507 llSetTimerEvent(0);
554 } 508 }
555 } 509 }
556   510  
557 state stop_flight { 511 state stop_flight {
558 state_entry() { 512 state_entry() {
559 // DEBUG 513 // DEBUG
560 llOwnerSay("Landing agent for walking..."); 514 llOwnerSay("Landing agent for walking...");
561 llRegionSayTo( 515 llRegionSayTo(
562 wasKeyValueGet( 516 wasKeyValueGet(
563 "corrade", 517 "corrade",
564 configuration 518 configuration
565 ), 519 ),
566 0, 520 0,
567 wasKeyValueEncode( 521 wasKeyValueEncode(
568 [ 522 [
569 "command", "fly", 523 "command", "fly",
570 "group", wasURLEscape( 524 "group", wasURLEscape(
571 wasKeyValueGet( 525 wasKeyValueGet(
572 "group", 526 "group",
573 configuration 527 configuration
574 ) 528 )
575 ), 529 ),
576 "password", wasURLEscape( 530 "password", wasURLEscape(
577 wasKeyValueGet( 531 wasKeyValueGet(
578 "password", 532 "password",
579 configuration 533 configuration
580 ) 534 )
581 ), 535 ),
582 "action", "stop", 536 "action", "stop",
583 "callback", wasURLEscape(callback) 537 "callback", wasURLEscape(callback)
584 ] 538 ]
585 ) 539 )
586 ); 540 );
587 llSetTimerEvent(60); 541 llSetTimerEvent(60);
588 } 542 }
589 timer() { 543 timer() {
590 state on; 544 state on;
591 } 545 }
592 touch_end(integer num) { 546 touch_end(integer num) {
593 llSetColor(<.5,0,0>, ALL_SIDES); 547 llSetColor(<.5,0,0>, ALL_SIDES);
594 llResetScript(); 548 llResetScript();
595 } 549 }
596 http_request(key id, string method, string body) { 550 http_request(key id, string method, string body) {
597 llHTTPResponse(id, 200, "OK"); 551 llHTTPResponse(id, 200, "OK");
598 if(wasKeyValueGet("command", body) != "fly" || 552 if(wasKeyValueGet("command", body) != "fly" ||
599 wasKeyValueGet("success", body) != "True") { 553 wasKeyValueGet("success", body) != "True") {
600 // DEBUG 554 // DEBUG
601 llOwnerSay("Landing failed..."); 555 llOwnerSay("Landing failed...");
602 state on; 556 state on;
603 } 557 }
604 llOwnerSay("Landed..."); 558 llOwnerSay("Landed...");
605 state walk; 559 state walk;
606 } 560 }
607 attach(key id) { 561 attach(key id) {
608 llResetScript(); 562 llResetScript();
609 } 563 }
610 on_rez(integer num) { 564 on_rez(integer num) {
611 llResetScript(); 565 llResetScript();
612 } 566 }
613 changed(integer change) { 567 changed(integer change) {
614 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 568 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
615 llResetScript(); 569 llResetScript();
616 if( 570 if(
617 (change & CHANGED_REGION_START) || 571 (change & CHANGED_REGION_START) ||
618 (change & CHANGED_REGION)) { 572 (change & CHANGED_REGION)) {
619 state on; 573 state on;
620 } 574 }
621 } 575 }
622 state_exit() { 576 state_exit() {
623 llSetTimerEvent(0); 577 llSetTimerEvent(0);
624 } 578 }
625 } 579 }
626   580  
627 state walk { 581 state walk {
628 state_entry() { 582 state_entry() {
629 // DEBUG 583 // DEBUG
630 llOwnerSay("Walking to agent..."); 584 llOwnerSay("Walking to agent...");
631 llRegionSayTo( 585 llRegionSayTo(
632 (key)wasKeyValueGet( 586 (key)wasKeyValueGet(
633 "corrade", 587 "corrade",
634 configuration 588 configuration
635 ), 589 ),
636 0, 590 0,
637 wasKeyValueEncode( 591 wasKeyValueEncode(
638 [ 592 [
639 "command", "autopilot", 593 "command", "walkto",
640 "group", wasURLEscape( 594 "group", wasURLEscape(
641 wasKeyValueGet( 595 wasKeyValueGet(
642 "group", 596 "group",
643 configuration 597 configuration
644 ) 598 )
645 ), 599 ),
646 "password", wasURLEscape( 600 "password", wasURLEscape(
647 wasKeyValueGet( 601 wasKeyValueGet(
648 "password", 602 "password",
649 configuration 603 configuration
650 ) 604 )
651 ), 605 ),
652 // move in a radius around the current primitive. 606 // move in a radius around the current primitive.
653 "position", llGetPos() + wasCirclePoint( 607 "position", llGetPos() + wasCirclePoint(
654 (integer)wasURLEscape( 608 (integer)wasURLEscape(
655 wasKeyValueGet( 609 wasKeyValueGet(
656 "range", 610 "range",
657 configuration 611 configuration
658 ) 612 )
659 ) 613 )
660 ), 614 ),
-   615 "vicinity", wasCirclePoint(
-   616 (integer)wasURLEscape(
-   617 wasKeyValueGet(
-   618 "range",
-   619 configuration
-   620 )
-   621 )
-   622 ),
661 "action", "start", 623 "duration", "2500",
662 "callback", wasURLEscape(callback) 624 "callback", wasURLEscape(callback)
663 ] 625 ]
664 ) 626 )
665 ); 627 );
666 llSetTimerEvent(60); 628 llSetTimerEvent(60);
667 } 629 }
668 timer() { 630 timer() {
669 state on; 631 state on;
670 } 632 }
671 touch_end(integer num) { 633 touch_end(integer num) {
672 llSetColor(<.5,0,0>, ALL_SIDES); 634 llSetColor(<.5,0,0>, ALL_SIDES);
673 llResetScript(); 635 llResetScript();
674 } 636 }
675 http_request(key id, string method, string body) { 637 http_request(key id, string method, string body) {
676 llHTTPResponse(id, 200, "OK"); 638 llHTTPResponse(id, 200, "OK");
677 if(wasKeyValueGet("command", body) != "autopilot" || 639 if(wasKeyValueGet("command", body) != "walkto" ||
678 wasKeyValueGet("success", body) != "True") { 640 wasKeyValueGet("success", body) != "True") {
679 // DEBUG 641 // DEBUG
680 llOwnerSay("Failed to start autopilot..."); 642 llOwnerSay("Failed to start walkto...");
681 state on; 643 state on;
682 } 644 }
683 state select; 645 state select;
684 } 646 }
685 attach(key id) { 647 attach(key id) {
686 llResetScript(); 648 llResetScript();
687 } 649 }
688 on_rez(integer num) { 650 on_rez(integer num) {
689 llResetScript(); 651 llResetScript();
690 } 652 }
691 changed(integer change) { 653 changed(integer change) {
692 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER)) 654 if(change & CHANGED_INVENTORY || (change & CHANGED_OWNER))
693 llResetScript(); 655 llResetScript();
694 if( 656 if(
695 (change & CHANGED_REGION_START) || 657 (change & CHANGED_REGION_START) ||
696 (change & CHANGED_REGION)) { 658 (change & CHANGED_REGION)) {
697 state on; 659 state on;
698 } 660 }
699 } 661 }
700 state_exit() { 662 state_exit() {
701 llSetTimerEvent(0); 663 llSetTimerEvent(0);
702 } 664 }
703 } 665 }
704   666