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

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 29 Rev 32
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // 2 // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 //
3 /////////////////////////////////////////////////////////////////////////// 3 ///////////////////////////////////////////////////////////////////////////
4 // 4 //
5 // This script is used to make Corrade sit on a primitive. The script first 5 // This script is used to make Corrade sit on a primitive. The script first
6 // uses a Corrade command to scan the surrounding area for primitives and 6 // uses a Corrade command to scan the surrounding area for primitives and
7 // then sends a command to make Corrade sit on that primitive. 7 // then sends a command to make Corrade sit on that primitive.
8 // 8 //
9 // For more information on Corrade, please see: 9 // For more information on Corrade, please see:
10 // http://grimore.org/secondlife/scripted_agents/corrade 10 // http://grimore.org/secondlife/scripted_agents/corrade
11 // 11 //
12 /////////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////////
13   13  
14 /////////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////////
15 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // 15 // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
16 /////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////
17 string wasKeyValueGet(string k, string data) { 17 string wasKeyValueGet(string k, string data) {
18 if(llStringLength(data) == 0) return ""; 18 if(llStringLength(data) == 0) return "";
19 if(llStringLength(k) == 0) return ""; 19 if(llStringLength(k) == 0) return "";
20 list a = llParseString2List(data, ["&", "="], []); 20 list a = llParseString2List(data, ["&", "="], []);
21 integer i = llListFindList(a, [ k ]); 21 integer i = llListFindList(a, [ k ]);
22 if(i != -1) return llList2String(a, i+1); 22 if(i != -1) return llList2String(a, i+1);
23 return ""; 23 return "";
24 } 24 }
25 25
26 /////////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////////
27 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 27 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
28 /////////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////////
29 string wasKeyValueEncode(list data) { 29 string wasKeyValueEncode(list data) {
30 list k = llList2ListStrided(data, 0, -1, 2); 30 list k = llList2ListStrided(data, 0, -1, 2);
31 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); 31 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2);
32 data = []; 32 data = [];
33 do { 33 do {
34 data += llList2String(k, 0) + "=" + llList2String(v, 0); 34 data += llList2String(k, 0) + "=" + llList2String(v, 0);
35 k = llDeleteSubList(k, 0, 0); 35 k = llDeleteSubList(k, 0, 0);
36 v = llDeleteSubList(v, 0, 0); 36 v = llDeleteSubList(v, 0, 0);
37 } while(llGetListLength(k) != 0); 37 } while(llGetListLength(k) != 0);
38 return llDumpList2String(data, "&"); 38 return llDumpList2String(data, "&");
39 } 39 }
40   40  
41 /////////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////////
42 // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // 42 // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
43 /////////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////////
44 // http://was.fm/secondlife/wanderer 44 // http://was.fm/secondlife/wanderer
45 vector wasCirclePoint(float radius) { 45 vector wasCirclePoint(float radius) {
46 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 46 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
47 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 47 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
48 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) 48 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2))
49 return <x, y, 0>; 49 return <x, y, 0>;
50 return wasCirclePoint(radius); 50 return wasCirclePoint(radius);
51 } 51 }
52   52  
53 /////////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////////
54 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 54 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
55 /////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////
56 // escapes a string in conformance with RFC1738 56 // escapes a string in conformance with RFC1738
57 string wasURLEscape(string i) { 57 string wasURLEscape(string i) {
58 string o = ""; 58 string o = "";
59 do { 59 do {
60 string c = llGetSubString(i, 0, 0); 60 string c = llGetSubString(i, 0, 0);
61 i = llDeleteSubString(i, 0, 0); 61 i = llDeleteSubString(i, 0, 0);
62 if(c == "") jump continue; 62 if(c == "") jump continue;
63 if(c == " ") { 63 if(c == " ") {
64 o += "+"; 64 o += "+";
65 jump continue; 65 jump continue;
66 } 66 }
67 if(c == "\n") { 67 if(c == "\n") {
68 o += "%0D" + llEscapeURL(c); 68 o += "%0D" + llEscapeURL(c);
69 jump continue; 69 jump continue;
70 } 70 }
71 o += llEscapeURL(c); 71 o += llEscapeURL(c);
72 @continue; 72 @continue;
73 } while(i != ""); 73 } while(i != "");
74 return o; 74 return o;
75 } 75 }
76   76  
77 /////////////////////////////////////////////////////////////////////////// 77 ///////////////////////////////////////////////////////////////////////////
78 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 78 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
79 /////////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////////
80 list wasCSVToList(string csv) { 80 list wasCSVToList(string csv) {
81 list l = []; 81 list l = [];
82 list s = []; 82 list s = [];
83 string m = ""; 83 string m = "";
84 do { 84 do {
85 string a = llGetSubString(csv, 0, 0); 85 string a = llGetSubString(csv, 0, 0);
86 csv = llDeleteSubString(csv, 0, 0); 86 csv = llDeleteSubString(csv, 0, 0);
87 if(a == ",") { 87 if(a == ",") {
88 if(llList2String(s, -1) != "\"") { 88 if(llList2String(s, -1) != "\"") {
89 l += m; 89 l += m;
90 m = ""; 90 m = "";
91 jump continue; 91 jump continue;
92 } 92 }
93 m += a; 93 m += a;
94 jump continue; 94 jump continue;
95 } 95 }
96 if(a == "\"" && llGetSubString(csv, 0, 0) == a) { 96 if(a == "\"" && llGetSubString(csv, 0, 0) == a) {
97 m += a; 97 m += a;
98 csv = llDeleteSubString(csv, 0, 0); 98 csv = llDeleteSubString(csv, 0, 0);
99 jump continue; 99 jump continue;
100 } 100 }
101 if(a == "\"") { 101 if(a == "\"") {
102 if(llList2String(s, -1) != a) { 102 if(llList2String(s, -1) != a) {
103 s += a; 103 s += a;
104 jump continue; 104 jump continue;
105 } 105 }
106 s = llDeleteSubList(s, -1, -1); 106 s = llDeleteSubList(s, -1, -1);
107 jump continue; 107 jump continue;
108 } 108 }
109 m += a; 109 m += a;
110 @continue; 110 @continue;
111 } while(csv != ""); 111 } while(csv != "");
112 // postcondition: length(s) = 0 112 // postcondition: length(s) = 0
113 return l + m; 113 return l + m;
114 } 114 }
115   115  
116 /////////////////////////////////////////////////////////////////////////// 116 ///////////////////////////////////////////////////////////////////////////
117 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 117 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
118 /////////////////////////////////////////////////////////////////////////// 118 ///////////////////////////////////////////////////////////////////////////
119 string wasListToCSV(list l) { 119 string wasListToCSV(list l) {
120 list v = []; 120 list v = [];
121 do { 121 do {
122 string a = llDumpList2String( 122 string a = llDumpList2String(
123 llParseStringKeepNulls( 123 llParseStringKeepNulls(
124 llList2String( 124 llList2String(
125 l, 125 l,
126 0 126 0
127 ), 127 ),
128 ["\""], 128 ["\""],
129 [] 129 []
130 ), 130 ),
131 "\"\"" 131 "\"\""
132 ); 132 );
133 if(llParseStringKeepNulls( 133 if(llParseStringKeepNulls(
134 a, 134 a,
135 [" ", ",", "\n", "\""], [] 135 [" ", ",", "\n", "\""], []
136 ) != 136 ) !=
137 (list) a 137 (list) a
138 ) a = "\"" + a + "\""; 138 ) a = "\"" + a + "\"";
139 v += a; 139 v += a;
140 l = llDeleteSubList(l, 0, 0); 140 l = llDeleteSubList(l, 0, 0);
141 } while(l != []); 141 } while(l != []);
142 return llDumpList2String(v, ","); 142 return llDumpList2String(v, ",");
143 } 143 }
144   144  
145 /////////////////////////////////////////////////////////////////////////// 145 ///////////////////////////////////////////////////////////////////////////
146 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 146 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
147 /////////////////////////////////////////////////////////////////////////// 147 ///////////////////////////////////////////////////////////////////////////
148 // unescapes a string in conformance with RFC1738 148 // unescapes a string in conformance with RFC1738
149 string wasURLUnescape(string i) { 149 string wasURLUnescape(string i) {
150 return llUnescapeURL( 150 return llUnescapeURL(
151 llDumpList2String( 151 llDumpList2String(
152 llParseString2List( 152 llParseString2List(
153 llDumpList2String( 153 llDumpList2String(
154 llParseString2List( 154 llParseString2List(
155 i, 155 i,
156 ["+"], 156 ["+"],
157 [] 157 []
158 ), 158 ),
159 " " 159 " "
160 ), 160 ),
161 ["%0D%0A"], 161 ["%0D%0A"],
162 [] 162 []
163 ), 163 ),
164 "\n" 164 "\n"
165 ) 165 )
166 ); 166 );
167 } 167 }
168   168  
169 /////////////////////////////////////////////////////////////////////////// 169 ///////////////////////////////////////////////////////////////////////////
170 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 170 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
171 /////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////
172 integer wasMenuIndex = 0; 172 integer wasMenuIndex = 0;
173 list wasDialogMenu(list input, list actions, string direction) { 173 list wasDialogMenu(list input, list actions, string direction) {
174 integer cut = 11-wasListCountExclude(actions, [""]); 174 integer cut = 11-wasListCountExclude(actions, [""]);
175 if(direction == ">" && (wasMenuIndex+1)*cut+wasMenuIndex+1 < llGetListLength(input)) { 175 if(direction == ">" && (wasMenuIndex+1)*cut+wasMenuIndex+1 < llGetListLength(input)) {
176 ++wasMenuIndex; 176 ++wasMenuIndex;
177 jump slice; 177 jump slice;
178 } 178 }
179 if(direction == "<" && wasMenuIndex-1 >= 0) { 179 if(direction == "<" && wasMenuIndex-1 >= 0) {
180 --wasMenuIndex; 180 --wasMenuIndex;
181 jump slice; 181 jump slice;
182 } 182 }
183 @slice; 183 @slice;
184 integer multiple = wasMenuIndex*cut; 184 integer multiple = wasMenuIndex*cut;
185 input = llList2List(input, multiple+wasMenuIndex, multiple+cut+wasMenuIndex); 185 input = llList2List(input, multiple+wasMenuIndex, multiple+cut+wasMenuIndex);
186 input = wasListMerge(input, actions, ""); 186 input = wasListMerge(input, actions, "");
187 return input; 187 return input;
188 } 188 }
189 189
190 /////////////////////////////////////////////////////////////////////////// 190 ///////////////////////////////////////////////////////////////////////////
191 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 191 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
192 /////////////////////////////////////////////////////////////////////////// 192 ///////////////////////////////////////////////////////////////////////////
193 integer wasListCountExclude(list input, list exclude) { 193 integer wasListCountExclude(list input, list exclude) {
194 if(llGetListLength(input) == 0) return 0; 194 if(llGetListLength(input) == 0) return 0;
195 if(llListFindList(exclude, (list)llList2String(input, 0)) == -1) 195 if(llListFindList(exclude, (list)llList2String(input, 0)) == -1)
196 return 1 + wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); 196 return 1 + wasListCountExclude(llDeleteSubList(input, 0, 0), exclude);
197 return wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); 197 return wasListCountExclude(llDeleteSubList(input, 0, 0), exclude);
198 } 198 }
199 199
200 /////////////////////////////////////////////////////////////////////////// 200 ///////////////////////////////////////////////////////////////////////////
201 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 201 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
202 /////////////////////////////////////////////////////////////////////////// 202 ///////////////////////////////////////////////////////////////////////////
203 list wasListMerge(list l, list m, string merge) { 203 list wasListMerge(list l, list m, string merge) {
204 if(llGetListLength(l) == 0 && llGetListLength(m) == 0) return []; 204 if(llGetListLength(l) == 0 && llGetListLength(m) == 0) return [];
205 string a = llList2String(m, 0); 205 string a = llList2String(m, 0);
206 if(a != merge) return [ a ] + wasListMerge(l, llDeleteSubList(m, 0, 0), merge); 206 if(a != merge) return [ a ] + wasListMerge(l, llDeleteSubList(m, 0, 0), merge);
207 return [ llList2String(l, 0) ] + wasListMerge(llDeleteSubList(l, 0, 0), llDeleteSubList(m, 0, 0), merge); 207 return [ llList2String(l, 0) ] + wasListMerge(llDeleteSubList(l, 0, 0), llDeleteSubList(m, 0, 0), merge);
208 } 208 }
209   209  
210 // configuration data 210 // configuration data
211 string configuration = ""; 211 string configuration = "";
212 // callback URL 212 // callback URL
213 string callback = ""; 213 string callback = "";
214 // scanned primitives 214 // scanned primitives
215 list names = []; 215 list names = [];
216 list UUIDs = []; 216 list UUIDs = [];
217 // temporary list for button name normalization 217 // temporary list for button name normalization
218 list menu = []; 218 list menu = [];
219 integer select = -1; 219 integer select = -1;
-   220  
220   221  
221 default { 222 default {
222 state_entry() { 223 state_entry() {
223 llSetTimerEvent(1); 224 llSetTimerEvent(1);
224 } 225 }
225 link_message(integer sender, integer num, string message, key id) { 226 link_message(integer sender, integer num, string message, key id) {
226 if(sender != 1 || id != "configuration") return; 227 if(sender != 1 || id != "configuration") return;
227 configuration = message; 228 configuration = message;
228 state off; 229 state off;
229 } 230 }
230 timer() { 231 timer() {
231 llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY); 232 llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY);
232 } 233 }
233 attach(key id) { 234 attach(key id) {
234 llResetScript(); 235 llResetScript();
235 } 236 }
236 on_rez(integer num) { 237 on_rez(integer num) {
237 llResetScript(); 238 llResetScript();
238 } 239 }
239 changed(integer change) { 240 changed(integer change) {
240 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 241 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
241 llResetScript(); 242 llResetScript();
242 } 243 }
243 } 244 }
244 state_exit() { 245 state_exit() {
245 llSetTimerEvent(0); 246 llSetTimerEvent(0);
246 } 247 }
247 } 248 }
248   249  
249 state off { 250 state off {
250 state_entry() { 251 state_entry() {
251 llSetColor(<.5,0,0>, ALL_SIDES); 252 llSetColor(<.5,0,0>, ALL_SIDES);
252 } 253 }
253 touch_end(integer num) { 254 touch_end(integer num) {
254 state on; 255 state on;
255 } 256 }
256 attach(key id) { 257 attach(key id) {
257 llResetScript(); 258 llResetScript();
258 } 259 }
259 on_rez(integer num) { 260 on_rez(integer num) {
260 llResetScript(); 261 llResetScript();
261 } 262 }
262 changed(integer change) { 263 changed(integer change) {
263 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 264 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
264 llResetScript(); 265 llResetScript();
265 } 266 }
266 } 267 }
267 } 268 }
268   269  
269 state on { 270 state on {
270 state_entry() { 271 state_entry() {
271 llSetColor(<0,.5,0>, ALL_SIDES); 272 llSetColor(<0,.5,0>, ALL_SIDES);
272 state url; 273 state url;
273 } 274 }
274 attach(key id) { 275 attach(key id) {
275 llResetScript(); 276 llResetScript();
276 } 277 }
277 on_rez(integer num) { 278 on_rez(integer num) {
278 llResetScript(); 279 llResetScript();
279 } 280 }
280 changed(integer change) { 281 changed(integer change) {
281 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 282 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
282 llResetScript(); 283 llResetScript();
283 } 284 }
284 } 285 }
285 } 286 }
286 287
287 state url { 288 state url {
288 state_entry() { 289 state_entry() {
289 // DEBUG 290 // DEBUG
290 llOwnerSay("Requesting URL..."); 291 llOwnerSay("Requesting URL...");
291 llRequestURL(); 292 llRequestURL();
292 } 293 }
293 touch_end(integer num) { 294 touch_end(integer num) {
294 llSetColor(<.5,0,0>, ALL_SIDES); 295 llSetColor(<.5,0,0>, ALL_SIDES);
295 llResetScript(); 296 llResetScript();
296 } 297 }
297 http_request(key id, string method, string body) { 298 http_request(key id, string method, string body) {
298 if(method != URL_REQUEST_GRANTED) return; 299 if(method != URL_REQUEST_GRANTED) return;
299 callback = body; 300 callback = body;
300 // DEBUG 301 // DEBUG
301 llOwnerSay("Got URL..."); 302 llOwnerSay("Got URL...");
302 state scan; 303 state scan;
303 } 304 }
304 attach(key id) { 305 attach(key id) {
305 llResetScript(); 306 llResetScript();
306 } 307 }
307 on_rez(integer num) { 308 on_rez(integer num) {
308 llResetScript(); 309 llResetScript();
309 } 310 }
310 changed(integer change) { 311 changed(integer change) {
311 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 312 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
312 llResetScript(); 313 llResetScript();
313 } 314 }
314 } 315 }
315 } 316 }
316   317  
317 state scan { 318 state scan {
318 state_entry() { 319 state_entry() {
319 // DEBUG 320 // DEBUG
320 llOwnerSay("Getting objects..."); 321 llOwnerSay("Getting objects...");
321 llInstantMessage( 322 llInstantMessage(
322 wasKeyValueGet( 323 wasKeyValueGet(
323 "corrade", 324 "corrade",
324 configuration 325 configuration
325 ), 326 ),
326 wasKeyValueEncode( 327 wasKeyValueEncode(
327 [ 328 [
328 "command", "getobjectsdata", 329 "command", "getobjectsdata",
329 "group", wasURLEscape( 330 "group", wasURLEscape(
330 wasKeyValueGet( 331 wasKeyValueGet(
331 "group", 332 "group",
332 configuration 333 configuration
333 ) 334 )
334 ), 335 ),
335 "password", wasURLEscape( 336 "password", wasURLEscape(
336 wasKeyValueGet( 337 wasKeyValueGet(
337 "password", 338 "password",
338 configuration 339 configuration
339 ) 340 )
340 ), 341 ),
341 "entity", "world", 342 "entity", "world",
342 "range", wasURLEscape( 343 "range", wasURLEscape(
343 wasKeyValueGet( 344 wasKeyValueGet(
344 "radar", 345 "radar",
345 configuration 346 configuration
346 ) 347 )
347 ), 348 ),
348 "data", wasListToCSV( 349 "data", wasListToCSV(
349 [ 350 [
350 "Properties.Name", 351 "Properties.Name",
351 "ID" 352 "ID"
352 ] 353 ]
353 ), 354 ),
354 "sift", wasListToCSV( 355 "sift", wasListToCSV(
355 [ 356 [
356 "take", 32 357 "take", 32
357 ] 358 ]
358 ), 359 ),
359 "callback", wasURLEscape(callback) 360 "callback", wasURLEscape(callback)
360 ] 361 ]
361 ) 362 )
362 ); 363 );
363 } 364 }
364 touch_end(integer num) { 365 touch_end(integer num) {
365 llSetColor(<.5,0,0>, ALL_SIDES); 366 llSetColor(<.5,0,0>, ALL_SIDES);
366 llResetScript(); 367 llResetScript();
367 } 368 }
368 http_request(key id, string method, string body) { 369 http_request(key id, string method, string body) {
369 llHTTPResponse(id, 200, "OK"); 370 llHTTPResponse(id, 200, "OK");
370 if(wasKeyValueGet("command", body) != "getobjectsdata" || 371 if(wasKeyValueGet("command", body) != "getobjectsdata" ||
371 wasKeyValueGet("success", body) != "True") { 372 wasKeyValueGet("success", body) != "True") {
372 // DEBUG 373 // DEBUG
373 llOwnerSay("Error querying primitives: " + wasKeyValueGet("error", body)); 374 llOwnerSay("Error querying primitives: " + wasKeyValueGet("error", body));
374 llResetScript(); 375 llResetScript();
375 } 376 }
376 string dataKey = wasURLUnescape( 377 string dataKey = wasURLUnescape(
377 wasKeyValueGet( 378 wasKeyValueGet(
378 "data", 379 "data",
379 body 380 body
380 ) 381 )
381 ); 382 );
382 if(dataKey == "") { 383 if(dataKey == "") {
383 // DEBUG 384 // DEBUG
384 llOwnerSay("No data for scanned primitives..."); 385 llOwnerSay("No data for scanned primitives...");
385 llResetScript(); 386 llResetScript();
386 } 387 }
387 list data = wasCSVToList(dataKey); 388 list data = wasCSVToList(dataKey);
388 // Copy the names and UUIDs of the primitives. 389 // Copy the names and UUIDs of the primitives.
389 names = []; 390 names = [];
390 UUIDs = []; 391 UUIDs = [];
391 do { 392 do {
392 string v = llList2String(data, -1); 393 string v = llList2String(data, -1);
393 data = llDeleteSubList(data, -1, -1); 394 data = llDeleteSubList(data, -1, -1);
394 string k = llList2String(data, -1); 395 string k = llList2String(data, -1);
395 data = llDeleteSubList(data, -1, -1); 396 data = llDeleteSubList(data, -1, -1);
396 if(k == "Properties.Name") { 397 if(k == "Properties.Name") {
-   398 // Corrade may pass blank names due to SL
-   399 // objects not being yet discovered.
-   400 if(v == "") {
-   401 names += "Unknown";
-   402 jump continue;
-   403 }
397 names += v; 404 names += v;
398 jump continue; 405 jump continue;
399 } 406 }
400 UUIDs += (key)v; 407 UUIDs += (key)v;
401 @continue; 408 @continue;
402 } while(llGetListLength(data)); 409 } while(llGetListLength(data));
403 state choose; 410 state choose;
404 } 411 }
405 attach(key id) { 412 attach(key id) {
406 llResetScript(); 413 llResetScript();
407 } 414 }
408 on_rez(integer num) { 415 on_rez(integer num) {
409 llResetScript(); 416 llResetScript();
410 } 417 }
411 changed(integer change) { 418 changed(integer change) {
412 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 419 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
413 llResetScript(); 420 llResetScript();
414 } 421 }
415 } 422 }
416 state_exit() { 423 state_exit() {
417 llSetTimerEvent(0); 424 llSetTimerEvent(0);
418 } 425 }
419 } 426 }
420   427  
421 state choose { 428 state choose {
422 state_entry() { 429 state_entry() {
423 // DEBUG 430 // DEBUG
424 llOwnerSay("Sending menu..."); 431 llOwnerSay("Sending menu...");
425 menu = []; 432 menu = [];
426 integer i = 0; 433 integer i = 0;
427 do { 434 do {
428 menu += llGetSubString(llList2String(names, i), 0, 23); 435 menu += llGetSubString(llList2String(names, i), 0, 23);
429 } while(++i < llGetListLength(names)); 436 } while(++i < llGetListLength(names));
-   437 llOwnerSay("Menu: " + llDumpList2String(menu, ","));
430 llListen(-10, "", llGetOwner(), ""); 438 llListen(-10, "", llGetOwner(), "");
431 llDialog(llGetOwner(), "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ""), -10); 439 llDialog(llGetOwner(), "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ""), -10);
432 llSetTimerEvent(60); 440 llSetTimerEvent(60);
433 } 441 }
434 touch_end(integer num) { 442 touch_end(integer num) {
435 llSetColor(<.5,0,0>, ALL_SIDES); 443 llSetColor(<.5,0,0>, ALL_SIDES);
436 llResetScript(); 444 llResetScript();
437 } 445 }
438 listen(integer channel, string name, key id, string message) { 446 listen(integer channel, string name, key id, string message) {
439 if(message == "⟵ Back") { 447 if(message == "⟵ Back") {
440 llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], "<"), -10); 448 llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], "<"), -10);
441 return; 449 return;
442 } 450 }
443 if(message == "Next ⟶") { 451 if(message == "Next ⟶") {
444 llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ">"), -10); 452 llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ">"), -10);
445 return; 453 return;
446 } 454 }
447 integer i = llGetListLength(menu) - 1; 455 integer i = llGetListLength(menu) - 1;
448 do { 456 do {
449 string v = llList2String(menu, i); 457 string v = llList2String(menu, i);
450 if(llSubStringIndex(v, message) != -1) 458 if(llSubStringIndex(v, message) != -1)
451 jump sit; 459 jump sit;
452 } while(--i > -1); 460 } while(--i > -1);
453 // GC 461 // GC
454 menu = []; 462 menu = [];
455 // DEBUG 463 // DEBUG
456 llOwnerSay("Invalid menu item selected..."); 464 llOwnerSay("Invalid menu item selected...");
457 llResetScript(); 465 llResetScript();
458 @sit; 466 @sit;
459 // GC 467 // GC
460 menu = []; 468 menu = [];
461 select = i; 469 select = i;
462 // Got a menu item so bind to permission notifications and sit. 470 // Got a menu item so bind to permission notifications and sit.
463 state notify; 471 state notify;
464 472
465 } 473 }
466 timer() { 474 timer() {
467 // DEBUG 475 // DEBUG
468 llOwnerSay("Dialog menu timeout..."); 476 llOwnerSay("Dialog menu timeout...");
469 llResetScript(); 477 llResetScript();
470 } 478 }
471 attach(key id) { 479 attach(key id) {
472 llResetScript(); 480 llResetScript();
473 } 481 }
474 on_rez(integer num) { 482 on_rez(integer num) {
475 llResetScript(); 483 llResetScript();
476 } 484 }
477 changed(integer change) { 485 changed(integer change) {
478 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 486 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
479 llResetScript(); 487 llResetScript();
480 } 488 }
481 } 489 }
482 state_exit() { 490 state_exit() {
483 llSetTimerEvent(0); 491 llSetTimerEvent(0);
484 } 492 }
485 } 493 }
486   494  
487 state notify { 495 state notify {
488 state_entry() { 496 state_entry() {
489 // DEBUG 497 // DEBUG
490 llOwnerSay("Binding to the permission Corrade notification..."); 498 llOwnerSay("Binding to the permission Corrade notification...");
491 llInstantMessage( 499 llInstantMessage(
492 (key)wasKeyValueGet( 500 (key)wasKeyValueGet(
493 "corrade", 501 "corrade",
494 configuration 502 configuration
495 ), 503 ),
496 wasKeyValueEncode( 504 wasKeyValueEncode(
497 [ 505 [
498 "command", "notify", 506 "command", "notify",
499 "group", wasURLEscape( 507 "group", wasURLEscape(
500 wasKeyValueGet( 508 wasKeyValueGet(
501 "group", 509 "group",
502 configuration 510 configuration
503 ) 511 )
504 ), 512 ),
505 "password", wasURLEscape( 513 "password", wasURLEscape(
506 wasKeyValueGet( 514 wasKeyValueGet(
507 "password", 515 "password",
508 configuration 516 configuration
509 ) 517 )
510 ), 518 ),
511 "action", "add", 519 "action", "add",
512 "type", "permission", 520 "type", "permission",
513 "URL", wasURLEscape(callback), 521 "URL", wasURLEscape(callback),
514 "callback", wasURLEscape(callback) 522 "callback", wasURLEscape(callback)
515 ] 523 ]
516 ) 524 )
517 ); 525 );
518 llSetTimerEvent(60); 526 llSetTimerEvent(60);
519 } 527 }
520 touch_end(integer num) { 528 touch_end(integer num) {
521 llSetColor(<.5,0,0>, ALL_SIDES); 529 llSetColor(<.5,0,0>, ALL_SIDES);
522 llResetScript(); 530 llResetScript();
523 } 531 }
524 http_request(key id, string method, string body) { 532 http_request(key id, string method, string body) {
525 llHTTPResponse(id, 200, "OK"); 533 llHTTPResponse(id, 200, "OK");
526 if(wasKeyValueGet("command", body) != "notify" || 534 if(wasKeyValueGet("command", body) != "notify" ||
527 wasKeyValueGet("success", body) != "True") { 535 wasKeyValueGet("success", body) != "True") {
528 // DEBUG 536 // DEBUG
529 llOwnerSay("Failed to bind to the permission notification..."); 537 llOwnerSay("Failed to bind to the permission notification...");
530 llResetScript(); 538 llResetScript();
531 } 539 }
532 // DEBUG 540 // DEBUG
533 llOwnerSay("Permission notification installed..."); 541 llOwnerSay("Permission notification installed...");
534 state sit; 542 state sit;
535 } 543 }
536 timer() { 544 timer() {
537 // DEBUG 545 // DEBUG
538 llOwnerSay("Timeout binding to permission notification..."); 546 llOwnerSay("Timeout binding to permission notification...");
539 llResetScript(); 547 llResetScript();
540 } 548 }
541 attach(key id) { 549 attach(key id) {
542 llResetScript(); 550 llResetScript();
543 } 551 }
544 on_rez(integer num) { 552 on_rez(integer num) {
545 llResetScript(); 553 llResetScript();
546 } 554 }
547 changed(integer change) { 555 changed(integer change) {
548 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 556 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
549 llResetScript(); 557 llResetScript();
550 } 558 }
551 } 559 }
552 state_exit() { 560 state_exit() {
553 llSetTimerEvent(0); 561 llSetTimerEvent(0);
554 } 562 }
555 } 563 }
556 564
557 state sit { 565 state sit {
558 state_entry() { 566 state_entry() {
559 // DEBUG 567 // DEBUG
560 llOwnerSay("Sitting on: " + 568 llOwnerSay("Sitting on: " +
561 llList2String(names, select) + 569 llList2String(names, select) +
562 " UUID: " + 570 " UUID: " +
563 llList2String(UUIDs, select) 571 llList2String(UUIDs, select)
564 ); 572 );
565 llInstantMessage( 573 llInstantMessage(
566 (key)wasKeyValueGet( 574 (key)wasKeyValueGet(
567 "corrade", 575 "corrade",
568 configuration 576 configuration
569 ), 577 ),
570 wasKeyValueEncode( 578 wasKeyValueEncode(
571 [ 579 [
572 "command", "sit", 580 "command", "sit",
573 "group", wasURLEscape( 581 "group", wasURLEscape(
574 wasKeyValueGet( 582 wasKeyValueGet(
575 "group", 583 "group",
576 configuration 584 configuration
577 ) 585 )
578 ), 586 ),
579 "password", wasURLEscape( 587 "password", wasURLEscape(
580 wasKeyValueGet( 588 wasKeyValueGet(
581 "password", 589 "password",
582 configuration 590 configuration
583 ) 591 )
584 ), 592 ),
585 "item", wasURLEscape( 593 "item", wasURLEscape(
586 llList2String(UUIDs, select) 594 llList2String(UUIDs, select)
587 ), 595 ),
588 "range", wasURLEscape( 596 "range", wasURLEscape(
589 wasKeyValueGet( 597 wasKeyValueGet(
590 "radar", 598 "radar",
591 configuration 599 configuration
592 ) 600 )
593 ), 601 ),
594 "callback", wasURLEscape(callback) 602 "callback", wasURLEscape(callback)
595 ] 603 ]
596 ) 604 )
597 ); 605 );
598 llSetTimerEvent(60); 606 llSetTimerEvent(60);
599 } 607 }
600 touch_end(integer num) { 608 touch_end(integer num) {
601 state unbind; 609 state unbind;
602 } 610 }
603 http_request(key id, string method, string body) { 611 http_request(key id, string method, string body) {
604 llHTTPResponse(id, 200, "OK"); 612 llHTTPResponse(id, 200, "OK");
605 llSetTimerEvent(5); 613 llSetTimerEvent(5);
606 if(wasKeyValueGet("type", body) != "permission" || 614 if(wasKeyValueGet("type", body) != "permission" ||
607 wasKeyValueGet("permissions", body) != "TriggerAnimation") return; 615 wasKeyValueGet("permissions", body) != "TriggerAnimation") return;
608 llSetTimerEvent(10); 616 llSetTimerEvent(10);
609 // DEBUG 617 // DEBUG
610 llOwnerSay("Corrade received the permission request to trigger an animation, replying..."); 618 llOwnerSay("Corrade received the permission request to trigger an animation, replying...");
611 llInstantMessage( 619 llInstantMessage(
612 (key)wasKeyValueGet( 620 (key)wasKeyValueGet(
613 "corrade", 621 "corrade",
614 configuration 622 configuration
615 ), 623 ),
616 wasKeyValueEncode( 624 wasKeyValueEncode(
617 [ 625 [
618 "command", "replytoscriptpermissionrequest", 626 "command", "replytoscriptpermissionrequest",
619 "group", wasKeyValueGet( 627 "group", wasKeyValueGet(
620 "group", 628 "group",
621 configuration 629 configuration
622 ), 630 ),
623 "password", wasKeyValueGet( 631 "password", wasKeyValueGet(
624 "password", 632 "password",
625 configuration 633 configuration
626 ), 634 ),
627 "item", wasKeyValueGet( 635 "item", wasKeyValueGet(
628 "item", 636 "item",
629 body 637 body
630 ), 638 ),
631 "task", wasKeyValueGet( 639 "task", wasKeyValueGet(
632 "task", 640 "task",
633 body 641 body
634 ), 642 ),
635 "region", wasKeyValueGet( 643 "region", wasKeyValueGet(
636 "region", 644 "region",
637 body 645 body
638 ), 646 ),
639 "permissions", "TriggerAnimation", 647 "permissions", "TriggerAnimation",
640 "callback", wasURLEscape(callback) 648 "callback", wasURLEscape(callback)
641 ] 649 ]
642 ) 650 )
643 ); 651 );
644 llResetScript(); 652 llResetScript();
645 } 653 }
646 timer() { 654 timer() {
647 state unbind; 655 state unbind;
648 } 656 }
649 attach(key id) { 657 attach(key id) {
650 llResetScript(); 658 llResetScript();
651 } 659 }
652 on_rez(integer num) { 660 on_rez(integer num) {
653 llResetScript(); 661 llResetScript();
654 } 662 }
655 changed(integer change) { 663 changed(integer change) {
656 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 664 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
657 llResetScript(); 665 llResetScript();
658 } 666 }
659 } 667 }
660 state_exit() { 668 state_exit() {
661 llSetTimerEvent(0); 669 llSetTimerEvent(0);
662 } 670 }
663 } 671 }
664   672  
665 state unbind { 673 state unbind {
666 state_entry() { 674 state_entry() {
667 // DEBUG 675 // DEBUG
668 llOwnerSay("Unbinding from the permission Corrade notification..."); 676 llOwnerSay("Unbinding from the permission Corrade notification...");
669 llInstantMessage( 677 llInstantMessage(
670 (key)wasKeyValueGet( 678 (key)wasKeyValueGet(
671 "corrade", 679 "corrade",
672 configuration 680 configuration
673 ), 681 ),
674 wasKeyValueEncode( 682 wasKeyValueEncode(
675 [ 683 [
676 "command", "notify", 684 "command", "notify",
677 "group", wasURLEscape( 685 "group", wasURLEscape(
678 wasKeyValueGet( 686 wasKeyValueGet(
679 "group", 687 "group",
680 configuration 688 configuration
681 ) 689 )
682 ), 690 ),
683 "password", wasURLEscape( 691 "password", wasURLEscape(
684 wasKeyValueGet( 692 wasKeyValueGet(
685 "password", 693 "password",
686 configuration 694 configuration
687 ) 695 )
688 ), 696 ),
689 "action", "remove", 697 "action", "remove",
690 "type", "permission", 698 "type", "permission",
691 "URL", wasURLEscape(callback), 699 "URL", wasURLEscape(callback),
692 "callback", wasURLEscape(callback) 700 "callback", wasURLEscape(callback)
693 ] 701 ]
694 ) 702 )
695 ); 703 );
696 llSetTimerEvent(60); 704 llSetTimerEvent(60);
697 } 705 }
698 http_request(key id, string method, string body) { 706 http_request(key id, string method, string body) {
699 llHTTPResponse(id, 200, "OK"); 707 llHTTPResponse(id, 200, "OK");
700 if(wasKeyValueGet("command", body) != "notify" || 708 if(wasKeyValueGet("command", body) != "notify" ||
701 wasKeyValueGet("success", body) != "True") { 709 wasKeyValueGet("success", body) != "True") {
702 // DEBUG 710 // DEBUG
703 llOwnerSay("Failed to unbind from the permission notification..."); 711 llOwnerSay("Failed to unbind from the permission notification...");
704 llResetScript(); 712 llResetScript();
705 } 713 }
706 // DEBUG 714 // DEBUG
707 llOwnerSay("Permission notification uninstalled..."); 715 llOwnerSay("Permission notification uninstalled...");
708 llResetScript(); 716 llResetScript();
709 } 717 }
710 timer() { 718 timer() {
711 // DEBUG 719 // DEBUG
712 llOwnerSay("Timeout unbinding from the permission notification..."); 720 llOwnerSay("Timeout unbinding from the permission notification...");
713 llResetScript(); 721 llResetScript();
714 } 722 }
715 attach(key id) { 723 attach(key id) {
716 llResetScript(); 724 llResetScript();
717 } 725 }
718 on_rez(integer num) { 726 on_rez(integer num) {
719 llResetScript(); 727 llResetScript();
720 } 728 }
721 changed(integer change) { 729 changed(integer change) {
722 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { 730 if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) {
723 llResetScript(); 731 llResetScript();
724 } 732 }
725 } 733 }
726 state_exit() { 734 state_exit() {
727 llSetTimerEvent(0); 735 llSetTimerEvent(0);
728 } 736 }
729 } 737 }
730   738