corrade-lsl-templates – Diff between revs 29 and 30
?pathlinks?
Rev 29 | Rev 30 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2018 - License: CC BY 2.0 // |
2 | // Copyright (C) Wizardry and Steamworks 2018 - License: GNU GPLv3 // |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // |
4 | // |
|
5 | // A database-based joke module for Corrade Eggdrop. |
5 | // A database-based joke module for Corrade Eggdrop. |
|
6 | // |
6 | // |
|
7 | /////////////////////////////////////////////////////////////////////////// |
7 | /////////////////////////////////////////////////////////////////////////// |
|
Line 8... | Line 8... | |||
8 | |
8 | |
|
9 | /////////////////////////////////////////////////////////////////////////// |
9 | /////////////////////////////////////////////////////////////////////////// |
|
10 | // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // |
10 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
11 | /////////////////////////////////////////////////////////////////////////// |
11 | /////////////////////////////////////////////////////////////////////////// |
|
12 | string wasKeyValueGet(string k, string data) { |
12 | string wasKeyValueGet(string k, string data) { |
|
13 | if(llStringLength(data) == 0) return ""; |
13 | if(llStringLength(data) == 0) return ""; |
|
14 | if(llStringLength(k) == 0) return ""; |
14 | if(llStringLength(k) == 0) return ""; |
|
15 | list a = llParseString2List(data, ["&", "="], []); |
15 | list a = llParseString2List(data, ["&", "="], []); |
|
16 | integer i = llListFindList(a, [ k ]); |
16 | integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]); |
|
17 | if(i != -1) return llList2String(a, i+1); |
17 | if(i != -1) return llList2String(a, 2*i+1); |
|
18 | return ""; |
18 | return ""; |
|
Line 19... | Line 19... | |||
19 | } |
19 | } |
|
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); |
|
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 375... | Line 375... | |||
375 | ); |
375 | ); |
|
Line 376... | Line 376... | |||
376 | |
376 | |
|
377 | joke_counter = llList2Integer( |
377 | joke_counter = llList2Integer( |
|
378 | result, |
378 | result, |
|
379 | llListFindList(result, ["count"]) + 1 |
379 | llListFindList(result, ["count"]) + 1 |
|
Line 380... | Line 380... | |||
380 | ); |
380 | ) + 1; |
|
381 | |
381 | |
|
382 | llOwnerSay("[Joke] There are " + (string)joke_counter + " jokes in the database."); |
382 | llOwnerSay("[Joke] There are " + (string)joke_counter + " jokes in the database."); |
|
383 | state listen_group; |
383 | state listen_group; |
|
Line 409... | Line 409... | |||
409 | // We only care about notifications now. |
409 | // We only care about notifications now. |
|
410 | if(id != "notification") |
410 | if(id != "notification") |
|
411 | return; |
411 | return; |
|
Line 412... | Line 412... | |||
412 | |
412 | |
|
413 | // This script only processes group notifications. |
413 | // This script only processes group notifications. |
|
- | 414 | if(wasKeyValueGet("type", message) != "group" || |
||
- | 415 | (wasKeyValueGet("type", message) == "group" && |
||
- | 416 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
414 | if(wasKeyValueGet("type", message) != "group") |
417 | wasKeyValueGet("group", configuration))) |
|
Line 415... | Line 418... | |||
415 | return; |
418 | return; |
|
416 | |
419 | |
|
417 | // Get the message sender. |
420 | // Get the message sender. |
|
Line 476... | Line 479... | |||
476 | jump_state = "remove"; |
479 | jump_state = "remove"; |
|
477 | state url; |
480 | state url; |
|
478 | } |
481 | } |
|
Line 479... | Line 482... | |||
479 | |
482 | |
|
480 | data = llDumpList2String(command, " "); |
483 | data = llDumpList2String(command, " "); |
|
481 | if((integer)data == 0) |
484 | if((integer)data <= 0) |
|
482 | data = ""; |
485 | data = ""; |
|
483 | jump_state = "get"; |
486 | jump_state = "get"; |
|
484 | state url; |
487 | state url; |
|
485 | } |
488 | } |
|
Line 663... | Line 666... | |||
663 | } |
666 | } |
|
Line 664... | Line 667... | |||
664 | |
667 | |
|
665 | state add { |
668 | state add { |
|
666 | state_entry() { |
669 | state_entry() { |
|
667 | // DEBUG |
670 | // DEBUG |
|
668 | llOwnerSay("[Joke] Adding to database."); |
671 | llOwnerSay("[Joke] Adding to database: " + (string)(joke_counter + 1)); |
|
669 | llInstantMessage( |
672 | llInstantMessage( |
|
670 | wasKeyValueGet( |
673 | wasKeyValueGet( |
|
671 | "corrade", |
674 | "corrade", |
|
672 | configuration |
675 | configuration |
|
Line 722... | Line 725... | |||
722 | if(wasKeyValueGet("command", body) != "database" || |
725 | if(wasKeyValueGet("command", body) != "database" || |
|
723 | wasKeyValueGet("success", body) != "True") { |
726 | wasKeyValueGet("success", body) != "True") { |
|
724 | // DEBUG |
727 | // DEBUG |
|
725 | llOwnerSay("[Joke] Unable modify database: " + |
728 | llOwnerSay("[Joke] Unable modify database: " + |
|
726 | wasURLUnescape( |
729 | wasURLUnescape( |
|
727 | wasKeyValueGet("error", body) |
730 | wasKeyValueGet("data", body) |
|
728 | ) |
731 | ) |
|
729 | ); |
732 | ); |
|
730 | state listen_group; |
733 | state listen_group; |
|
731 | } |
734 | } |
|
732 | ++joke_counter; |
735 | ++joke_counter; |