corrade-lsl-templates – Diff between revs 41 and 42
?pathlinks?
Rev 41 | Rev 42 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // |
4 | // |
|
5 | // A module that spanks group members using fuzzy name matching. . . |
5 | // A module that spanks group members using fuzzy name matching. . . |
|
6 | // |
6 | // |
|
7 | /////////////////////////////////////////////////////////////////////////// |
7 | /////////////////////////////////////////////////////////////////////////// |
|
Line 17... | Line 17... | |||
17 | if(i != -1) return llList2String(a, 2*i+1); |
17 | if(i != -1) return llList2String(a, 2*i+1); |
|
18 | return ""; |
18 | return ""; |
|
19 | } |
19 | } |
|
Line 20... | Line 20... | |||
20 | |
20 | |
|
21 | /////////////////////////////////////////////////////////////////////////// |
21 | /////////////////////////////////////////////////////////////////////////// |
|
22 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
22 | // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // |
|
23 | /////////////////////////////////////////////////////////////////////////// |
23 | /////////////////////////////////////////////////////////////////////////// |
|
24 | string wasKeyValueEncode(list data) { |
24 | string wasKeyValueEncode(list data) { |
|
25 | list k = llList2ListStrided(data, 0, -1, 2); |
25 | list k = llList2ListStrided(data, 0, -1, 2); |
|
26 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
26 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
|
Line 32... | Line 32... | |||
32 | } while(llGetListLength(k) != 0); |
32 | } while(llGetListLength(k) != 0); |
|
33 | return llDumpList2String(data, "&"); |
33 | return llDumpList2String(data, "&"); |
|
34 | } |
34 | } |
|
Line 35... | Line 35... | |||
35 | |
35 | |
|
36 | /////////////////////////////////////////////////////////////////////////// |
36 | /////////////////////////////////////////////////////////////////////////// |
|
37 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
37 | // Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
|
38 | /////////////////////////////////////////////////////////////////////////// |
38 | /////////////////////////////////////////////////////////////////////////// |
|
39 | // http://was.fm/secondlife/wanderer |
39 | // http://was.fm/secondlife/wanderer |
|
40 | vector wasCirclePoint(float radius) { |
40 | vector wasCirclePoint(float radius) { |
|
41 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
41 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
Line 44... | Line 44... | |||
44 | return <x, y, 0>; |
44 | return <x, y, 0>; |
|
45 | return wasCirclePoint(radius); |
45 | return wasCirclePoint(radius); |
|
46 | } |
46 | } |
|
Line 47... | Line 47... | |||
47 | |
47 | |
|
48 | /////////////////////////////////////////////////////////////////////////// |
48 | /////////////////////////////////////////////////////////////////////////// |
|
49 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
49 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
|
50 | /////////////////////////////////////////////////////////////////////////// |
50 | /////////////////////////////////////////////////////////////////////////// |
|
51 | // escapes a string in conformance with RFC1738 |
51 | // escapes a string in conformance with RFC1738 |
|
52 | string wasURLEscape(string i) { |
52 | string wasURLEscape(string i) { |
|
53 | string o = ""; |
53 | string o = ""; |
|
Line 68... | Line 68... | |||
68 | } while(i != ""); |
68 | } while(i != ""); |
|
69 | return o; |
69 | return o; |
|
70 | } |
70 | } |
|
Line 71... | Line 71... | |||
71 | |
71 | |
|
72 | /////////////////////////////////////////////////////////////////////////// |
72 | /////////////////////////////////////////////////////////////////////////// |
|
73 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
73 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
|
74 | /////////////////////////////////////////////////////////////////////////// |
74 | /////////////////////////////////////////////////////////////////////////// |
|
75 | list wasCSVToList(string csv) { |
75 | list wasCSVToList(string csv) { |
|
76 | list l = []; |
76 | list l = []; |
|
77 | list s = []; |
77 | list s = []; |
|
Line 107... | Line 107... | |||
107 | // postcondition: length(s) = 0 |
107 | // postcondition: length(s) = 0 |
|
108 | return l + m; |
108 | return l + m; |
|
109 | } |
109 | } |
|
Line 110... | Line 110... | |||
110 | |
110 | |
|
111 | /////////////////////////////////////////////////////////////////////////// |
111 | /////////////////////////////////////////////////////////////////////////// |
|
112 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
112 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
|
113 | /////////////////////////////////////////////////////////////////////////// |
113 | /////////////////////////////////////////////////////////////////////////// |
|
114 | string wasListToCSV(list l) { |
114 | string wasListToCSV(list l) { |
|
115 | list v = []; |
115 | list v = []; |
|
116 | do { |
116 | do { |
|
Line 136... | Line 136... | |||
136 | } while(l != []); |
136 | } while(l != []); |
|
137 | return llDumpList2String(v, ","); |
137 | return llDumpList2String(v, ","); |
|
138 | } |
138 | } |
|
Line 139... | Line 139... | |||
139 | |
139 | |
|
140 | /////////////////////////////////////////////////////////////////////////// |
140 | /////////////////////////////////////////////////////////////////////////// |
|
141 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
141 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
|
142 | /////////////////////////////////////////////////////////////////////////// |
142 | /////////////////////////////////////////////////////////////////////////// |
|
143 | // unescapes a string in conformance with RFC1738 |
143 | // unescapes a string in conformance with RFC1738 |
|
144 | string wasURLUnescape(string i) { |
144 | string wasURLUnescape(string i) { |
|
145 | return llUnescapeURL( |
145 | return llUnescapeURL( |
|
Line 161... | Line 161... | |||
161 | ); |
161 | ); |
|
162 | } |
162 | } |
|
Line 163... | Line 163... | |||
163 | |
163 | |
|
164 | // configuration data |
164 | // configuration data |
|
165 | string configuration = ""; |
- | ||
166 | // callback URL |
- | ||
167 | string URL = ""; |
165 | string configuration = ""; |
|
168 | // store message over state. |
166 | // store message over state. |
|
Line 169... | Line 167... | |||
169 | string data = ""; |
167 | string data = ""; |
|
170 | |
168 | |
|
Line 207... | Line 205... | |||
207 | // We only care about notifications now. |
205 | // We only care about notifications now. |
|
208 | if(id != "notification") |
206 | if(id != "notification") |
|
209 | return; |
207 | return; |
|
Line 210... | Line 208... | |||
210 | |
208 | |
|
211 | // This script only processes group notifications. |
209 | // This script only processes group notifications. |
|
- | 210 | if(wasKeyValueGet("type", message) != "group" || |
||
- | 211 | (wasKeyValueGet("type", message) == "group" && |
||
- | 212 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
212 | if(wasKeyValueGet("type", message) != "group") |
213 | wasKeyValueGet("group", configuration))) |
|
Line 213... | Line 214... | |||
213 | return; |
214 | return; |
|
214 | |
215 | |
|
215 | // Get the sent message. |
216 | // Get the sent message. |
|
Line 235... | Line 236... | |||
235 | command = llDeleteSubList(command, 0, 0); |
236 | command = llDeleteSubList(command, 0, 0); |
|
Line 236... | Line 237... | |||
236 | |
237 | |
|
237 | // Dump the rest of the message. |
238 | // Dump the rest of the message. |
|
Line 238... | Line 239... | |||
238 | data = llDumpList2String(command, " "); |
239 | data = llDumpList2String(command, " "); |
|
239 | |
- | ||
240 | // Get an URL. |
- | ||
241 | state url; |
- | ||
242 | } |
- | ||
243 | on_rez(integer num) { |
- | ||
244 | llResetScript(); |
- | ||
245 | } |
- | ||
246 | changed(integer change) { |
- | ||
247 | if((change & CHANGED_INVENTORY) || |
- | ||
248 | (change & CHANGED_REGION_START) || |
- | ||
249 | (change & CHANGED_OWNER)) { |
- | ||
250 | llResetScript(); |
- | ||
251 | } |
- | ||
252 | } |
- | ||
253 | } |
- | ||
254 | |
- | ||
255 | state url { |
- | ||
256 | state_entry() { |
- | ||
257 | // DEBUG |
- | ||
258 | llOwnerSay("[Spank] Requesting URL..."); |
- | ||
259 | llRequestURL(); |
- | ||
260 | } |
- | ||
261 | http_request(key id, string method, string body) { |
- | ||
262 | if(method != URL_REQUEST_GRANTED) return; |
- | ||
263 | URL = body; |
- | ||
264 | // DEBUG |
240 | |
|
265 | llOwnerSay("[Spank] Got URL..."); |
241 | // Search for member. |
|
266 | state search; |
242 | state search; |
|
267 | } |
243 | } |
|
268 | on_rez(integer num) { |
244 | on_rez(integer num) { |
|
Line 307... | Line 283... | |||
307 | "match", |
283 | "match", |
|
308 | wasURLEscape("(?i),?\"([^\",$]*" + data + "[^\",$]*)\",?") |
284 | wasURLEscape("(?i),?\"([^\",$]*" + data + "[^\",$]*)\",?") |
|
309 | ] |
285 | ] |
|
310 | ) |
286 | ) |
|
311 | ), |
287 | ), |
|
312 | "callback", wasURLEscape(URL) |
288 | "callback", wasURLEscape( |
|
- | 289 | wasKeyValueGet( |
||
- | 290 | "URL", |
||
- | 291 | configuration |
||
- | 292 | ) |
||
- | 293 | ) |
||
313 | ] |
294 | ] |
|
314 | ) |
295 | ) |
|
315 | ); |
296 | ); |
|
316 | llSetTimerEvent(60); |
297 | llSetTimerEvent(60); |
|
317 | } |
298 | } |
|
318 | http_request(key id, string method, string body) { |
299 | link_message(integer sender, integer num, string body, key id) { |
|
319 | llHTTPResponse(id, 200, "OK"); |
300 | // Only process callbacks for the database command. |
|
320 | llReleaseURL(URL); |
- | ||
321 | if(wasKeyValueGet("command", body) != "getmembers" || |
301 | if(id != "callback" || wasKeyValueGet("command", body) != "getmembers") |
|
- | 302 | return; |
||
- | 303 | |
||
322 | wasKeyValueGet("success", body) != "True") { |
304 | if(wasKeyValueGet("success", body) != "True") { |
|
323 | // DEBUG |
305 | // DEBUG |
|
324 | llOwnerSay("[Spank] Unable to get members: " + |
306 | llOwnerSay("[Spank] Unable to get members: " + |
|
325 | wasURLUnescape( |
307 | wasURLUnescape( |
|
326 | wasKeyValueGet("error", body) |
308 | wasKeyValueGet("error", body) |
|
327 | ) |
309 | ) |
|
Line 337... | Line 319... | |||
337 | ); |
319 | ); |
|
Line 338... | Line 320... | |||
338 | |
320 | |
|
339 | // Limit to two people to spank. |
321 | // Limit to two people to spank. |
|
340 | if(llGetListLength(spankees) > 2) { |
322 | if(llGetListLength(spankees) > 2) { |
|
341 | data = "So many people, so few hands!"; |
323 | data = "So many people, so few hands!"; |
|
342 | return; |
324 | state tell; |
|
Line 343... | Line 325... | |||
343 | } |
325 | } |
|
Line 344... | Line 326... | |||
344 | |
326 | |
|
Line 352... | Line 334... | |||
352 | data = "/me spanks " + data; |
334 | data = "/me spanks " + data; |
|
Line 353... | Line 335... | |||
353 | |
335 | |
|
354 | state tell; |
336 | state tell; |
|
355 | } |
337 | } |
|
356 | timer() { |
- | ||
357 | llReleaseURL(URL); |
338 | timer() { |
|
358 | state listen_group; |
339 | state listen_group; |
|
359 | } |
340 | } |
|
360 | on_rez(integer num) { |
341 | on_rez(integer num) { |
|
361 | llResetScript(); |
342 | llResetScript(); |