corrade-lsl-templates – Diff between revs 41 and 42

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 41 Rev 42
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 evaluates a mathematical expression for Corrade Eggdrop. 5 // A module that evaluates a mathematical expression for Corrade Eggdrop.
6 // 6 //
7 /////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////
8   8  
9 /////////////////////////////////////////////////////////////////////////// 9 ///////////////////////////////////////////////////////////////////////////
10 // Copyright (C) 2015 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 = llParseStringKeepNulls(data, ["&", "="], []); 15 list a = llParseStringKeepNulls(data, ["&", "="], []);
16 integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]); 16 integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
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 }
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);
27 data = []; 27 data = [];
28 do { 28 do {
29 data += llList2String(k, 0) + "=" + llList2String(v, 0); 29 data += llList2String(k, 0) + "=" + llList2String(v, 0);
30 k = llDeleteSubList(k, 0, 0); 30 k = llDeleteSubList(k, 0, 0);
31 v = llDeleteSubList(v, 0, 0); 31 v = llDeleteSubList(v, 0, 0);
32 } while(llGetListLength(k) != 0); 32 } while(llGetListLength(k) != 0);
33 return llDumpList2String(data, "&"); 33 return llDumpList2String(data, "&");
34 } 34 }
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);
42 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 42 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
43 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) 43 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2))
44 return <x, y, 0>; 44 return <x, y, 0>;
45 return wasCirclePoint(radius); 45 return wasCirclePoint(radius);
46 } 46 }
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 = "";
54 do { 54 do {
55 string c = llGetSubString(i, 0, 0); 55 string c = llGetSubString(i, 0, 0);
56 i = llDeleteSubString(i, 0, 0); 56 i = llDeleteSubString(i, 0, 0);
57 if(c == "") jump continue; 57 if(c == "") jump continue;
58 if(c == " ") { 58 if(c == " ") {
59 o += "+"; 59 o += "+";
60 jump continue; 60 jump continue;
61 } 61 }
62 if(c == "\n") { 62 if(c == "\n") {
63 o += "%0D" + llEscapeURL(c); 63 o += "%0D" + llEscapeURL(c);
64 jump continue; 64 jump continue;
65 } 65 }
66 o += llEscapeURL(c); 66 o += llEscapeURL(c);
67 @continue; 67 @continue;
68 } while(i != ""); 68 } while(i != "");
69 return o; 69 return o;
70 } 70 }
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 = [];
78 string m = ""; 78 string m = "";
79 do { 79 do {
80 string a = llGetSubString(csv, 0, 0); 80 string a = llGetSubString(csv, 0, 0);
81 csv = llDeleteSubString(csv, 0, 0); 81 csv = llDeleteSubString(csv, 0, 0);
82 if(a == ",") { 82 if(a == ",") {
83 if(llList2String(s, -1) != "\"") { 83 if(llList2String(s, -1) != "\"") {
84 l += m; 84 l += m;
85 m = ""; 85 m = "";
86 jump continue; 86 jump continue;
87 } 87 }
88 m += a; 88 m += a;
89 jump continue; 89 jump continue;
90 } 90 }
91 if(a == "\"" && llGetSubString(csv, 0, 0) == a) { 91 if(a == "\"" && llGetSubString(csv, 0, 0) == a) {
92 m += a; 92 m += a;
93 csv = llDeleteSubString(csv, 0, 0); 93 csv = llDeleteSubString(csv, 0, 0);
94 jump continue; 94 jump continue;
95 } 95 }
96 if(a == "\"") { 96 if(a == "\"") {
97 if(llList2String(s, -1) != a) { 97 if(llList2String(s, -1) != a) {
98 s += a; 98 s += a;
99 jump continue; 99 jump continue;
100 } 100 }
101 s = llDeleteSubList(s, -1, -1); 101 s = llDeleteSubList(s, -1, -1);
102 jump continue; 102 jump continue;
103 } 103 }
104 m += a; 104 m += a;
105 @continue; 105 @continue;
106 } while(csv != ""); 106 } while(csv != "");
107 // postcondition: length(s) = 0 107 // postcondition: length(s) = 0
108 return l + m; 108 return l + m;
109 } 109 }
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 {
117 string a = llDumpList2String( 117 string a = llDumpList2String(
118 llParseStringKeepNulls( 118 llParseStringKeepNulls(
119 llList2String( 119 llList2String(
120 l, 120 l,
121 0 121 0
122 ), 122 ),
123 ["\""], 123 ["\""],
124 [] 124 []
125 ), 125 ),
126 "\"\"" 126 "\"\""
127 ); 127 );
128 if(llParseStringKeepNulls( 128 if(llParseStringKeepNulls(
129 a, 129 a,
130 [" ", ",", "\n", "\""], [] 130 [" ", ",", "\n", "\""], []
131 ) != 131 ) !=
132 (list) a 132 (list) a
133 ) a = "\"" + a + "\""; 133 ) a = "\"" + a + "\"";
134 v += a; 134 v += a;
135 l = llDeleteSubList(l, 0, 0); 135 l = llDeleteSubList(l, 0, 0);
136 } while(l != []); 136 } while(l != []);
137 return llDumpList2String(v, ","); 137 return llDumpList2String(v, ",");
138 } 138 }
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(
146 llDumpList2String( 146 llDumpList2String(
147 llParseString2List( 147 llParseString2List(
148 llDumpList2String( 148 llDumpList2String(
149 llParseString2List( 149 llParseString2List(
150 i, 150 i,
151 ["+"], 151 ["+"],
152 [] 152 []
153 ), 153 ),
154 " " 154 " "
155 ), 155 ),
156 ["%0D%0A"], 156 ["%0D%0A"],
157 [] 157 []
158 ), 158 ),
159 "\n" 159 "\n"
160 ) 160 )
161 ); 161 );
162 } 162 }
163   163  
164 ////////////////////////////////////////////////////////// 164 //////////////////////////////////////////////////////////
165 // Returns a reversed list. 165 // Returns a reversed list.
166 ////////////////////////////////////////////////////////// 166 //////////////////////////////////////////////////////////
167 list wasListReverse(list lst) { 167 list wasListReverse(list lst) {
168 if(llGetListLength(lst)<=1) return lst; 168 if(llGetListLength(lst)<=1) return lst;
169 return wasListReverse(llList2List(lst, 1, llGetListLength(lst))) + llList2List(lst,0,0); 169 return wasListReverse(llList2List(lst, 1, llGetListLength(lst))) + llList2List(lst,0,0);
170 } 170 }
171 171  
172 ////////////////////////////////////////////////////////// 172 //////////////////////////////////////////////////////////
173 // Deletes elements delete from list input. 173 // Deletes elements delete from list input.
174 ////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////
175 list wasSubtractSubList(list input, list delete) { 175 list wasSubtractSubList(list input, list delete) {
176 do { 176 do {
177 string tok = llList2String(delete, 0); 177 string tok = llList2String(delete, 0);
178 list clean = input; 178 list clean = input;
179 do { 179 do {
180 if(llList2String(clean, 0) == tok) { 180 if(llList2String(clean, 0) == tok) {
181 integer idx = llListFindList(input, (list)tok); 181 integer idx = llListFindList(input, (list)tok);
182 input = llDeleteSubList(input, idx, idx); 182 input = llDeleteSubList(input, idx, idx);
183 } 183 }
184 } while(clean = llDeleteSubList(clean, 0, 0)); 184 } while(clean = llDeleteSubList(clean, 0, 0));
185 } while(delete = llDeleteSubList(delete, 0, 0)); 185 } while(delete = llDeleteSubList(delete, 0, 0));
186 return input; 186 return input;
187 } 187 }
188 188  
189 ////////////////////////////////////////////////////////// 189 //////////////////////////////////////////////////////////
190 // Returns a list of operators and operands. 190 // Returns a list of operators and operands.
191 ////////////////////////////////////////////////////////// 191 //////////////////////////////////////////////////////////
192 list wasInfixTokenize(string input) { 192 list wasInfixTokenize(string input) {
193 list op = [ "+", "-", "(", ")", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ]; 193 list op = [ "+", "-", "(", ")", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ];
194 list result = llParseString2List(input, [], op); 194 list result = llParseString2List(input, [], op);
195 return wasSubtractSubList(result, [" "]); 195 return wasSubtractSubList(result, [" "]);
196 } 196 }
197 197  
198 ////////////////////////////////////////////////////////// 198 //////////////////////////////////////////////////////////
199 // Transforms an infix expression to a postfix expression. 199 // Transforms an infix expression to a postfix expression.
200 ////////////////////////////////////////////////////////// 200 //////////////////////////////////////////////////////////
201 list wasInfixToPostfix(list infix) { 201 list wasInfixToPostfix(list infix) {
202 list op = [ "+", "-", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ]; 202 list op = [ "+", "-", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ];
203 list opStack = []; 203 list opStack = [];
204 list result = []; 204 list result = [];
205 do { 205 do {
206 string t = llList2String(infix, 0); 206 string t = llList2String(infix, 0);
207 infix = llDeleteSubList(infix, 0, 0); 207 infix = llDeleteSubList(infix, 0, 0);
208 if(t == "(") { 208 if(t == "(") {
209 opStack += "("; 209 opStack += "(";
210 jump continue; 210 jump continue;
211 } 211 }
212 if(t == ")") { 212 if(t == ")") {
213 while(llGetListLength(opStack) != 0) { 213 while(llGetListLength(opStack) != 0) {
214 string topa = llList2String(opStack, llGetListLength(opStack)-1); 214 string topa = llList2String(opStack, llGetListLength(opStack)-1);
215 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1); 215 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1);
216 if(topa != "(" && topa != ")") result += topa; 216 if(topa != "(" && topa != ")") result += topa;
217 } 217 }
218 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1); 218 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1);
219 jump continue; 219 jump continue;
220 } 220 }
221 integer idx = llListFindList(op, (list)t); 221 integer idx = llListFindList(op, (list)t);
222 if(idx == -1) { 222 if(idx == -1) {
223 result += t; 223 result += t;
224 jump continue; 224 jump continue;
225 } 225 }
226 @repeat; 226 @repeat;
227 string topb = llList2String(opStack, llGetListLength(opStack)-1); 227 string topb = llList2String(opStack, llGetListLength(opStack)-1);
228 integer odx = llListFindList(op, (list)topb); 228 integer odx = llListFindList(op, (list)topb);
229 if(odx >= idx) { 229 if(odx >= idx) {
230 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1); 230 opStack = llDeleteSubList(opStack, llGetListLength(opStack)-1, llGetListLength(opStack)-1);
231 result += topb; 231 result += topb;
232 if(llGetListLength(opStack) != 0) jump repeat; 232 if(llGetListLength(opStack) != 0) jump repeat;
233 } 233 }
234 opStack += t; 234 opStack += t;
235 @continue; 235 @continue;
236 } while(llGetListLength(infix) != 0); 236 } while(llGetListLength(infix) != 0);
237 result += wasListReverse(opStack); 237 result += wasListReverse(opStack);
238 return result; 238 return result;
239 } 239 }
240 240  
241 ////////////////////////////////////////////////////////// 241 //////////////////////////////////////////////////////////
242 // Evaluate a postfix expression. 242 // Evaluate a postfix expression.
243 ////////////////////////////////////////////////////////// 243 //////////////////////////////////////////////////////////
244 float wasPostfixEval(list postfix) { 244 float wasPostfixEval(list postfix) {
245 list op = [ "+", "-", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ]; 245 list op = [ "+", "-", "%", "*", "/", "^", "sin", "asin", "cos", "acos", "tan", "sqrt", "ln" ];
246 list orStack = []; 246 list orStack = [];
247 do { 247 do {
248 string t = llList2String(postfix, 0); 248 string t = llList2String(postfix, 0);
249 postfix = llDeleteSubList(postfix, 0, 0); 249 postfix = llDeleteSubList(postfix, 0, 0);
250 integer idx = llListFindList(op, (list)t); 250 integer idx = llListFindList(op, (list)t);
251 if(idx == -1) { 251 if(idx == -1) {
252 orStack += t; 252 orStack += t;
253 jump continue; 253 jump continue;
254 } 254 }
255 float a = llList2Float(orStack, llGetListLength(orStack)-1); 255 float a = llList2Float(orStack, llGetListLength(orStack)-1);
256 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 256 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
257 float b = llList2Float(orStack, llGetListLength(orStack)-1); 257 float b = llList2Float(orStack, llGetListLength(orStack)-1);
258 float r = 0; 258 float r = 0;
259 if(t == "+") { 259 if(t == "+") {
260 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 260 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
261 r = b + a; 261 r = b + a;
262 jump push; 262 jump push;
263 } 263 }
264 if(t == "-") { 264 if(t == "-") {
265 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 265 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
266 r = b - a; 266 r = b - a;
267 jump push; 267 jump push;
268 } 268 }
269 if(t == "*") { 269 if(t == "*") {
270 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 270 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
271 r = b * a; 271 r = b * a;
272 jump push; 272 jump push;
273 } 273 }
274 if(t == "/") { 274 if(t == "/") {
275 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 275 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
276 if(a == 0) { 276 if(a == 0) {
277 r = (float)"NaN"; 277 r = (float)"NaN";
278 jump push; 278 jump push;
279 } 279 }
280 r = b / a; 280 r = b / a;
281 jump push; 281 jump push;
282 } 282 }
283 if(t == "^") { 283 if(t == "^") {
284 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 284 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
285 r = llPow(b,a); 285 r = llPow(b,a);
286 jump push; 286 jump push;
287 } 287 }
288 if(t == "%") { 288 if(t == "%") {
289 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1); 289 orStack = llDeleteSubList(orStack, llGetListLength(orStack)-1, llGetListLength(orStack)-1);
290 r = (integer)b % (integer)a; 290 r = (integer)b % (integer)a;
291 jump push; 291 jump push;
292 } 292 }
293 if(t == "sin") { 293 if(t == "sin") {
294 r = llSin(a * DEG_TO_RAD); 294 r = llSin(a * DEG_TO_RAD);
295 jump push; 295 jump push;
296 } 296 }
297 if(t == "asin") { 297 if(t == "asin") {
298 r = llAsin(a * DEG_TO_RAD); 298 r = llAsin(a * DEG_TO_RAD);
299 jump push; 299 jump push;
300 } 300 }
301 if(t == "cos") { 301 if(t == "cos") {
302 r = llCos(a * DEG_TO_RAD); 302 r = llCos(a * DEG_TO_RAD);
303 jump push; 303 jump push;
304 } 304 }
305 if(t == "acos") { 305 if(t == "acos") {
306 r = llAcos(a * DEG_TO_RAD); 306 r = llAcos(a * DEG_TO_RAD);
307 jump push; 307 jump push;
308 } 308 }
309 if(t == "tan") { 309 if(t == "tan") {
310 r = llTan(a * DEG_TO_RAD); 310 r = llTan(a * DEG_TO_RAD);
311 jump push; 311 jump push;
312 } 312 }
313 if(t == "ln") { 313 if(t == "ln") {
314 r = llLog(a); 314 r = llLog(a);
315 jump push; 315 jump push;
316 } 316 }
317 if(t == "sqrt") { 317 if(t == "sqrt") {
318 r = llSqrt(a); 318 r = llSqrt(a);
319 } 319 }
320 @push; 320 @push;
321 orStack += r; 321 orStack += r;
322 @continue; 322 @continue;
323 } while(llGetListLength(postfix) != 0); 323 } while(llGetListLength(postfix) != 0);
324 return llList2Float(orStack, 0); 324 return llList2Float(orStack, 0);
325 } 325 }
326   326  
327 // configuration data 327 // configuration data
328 string configuration = ""; 328 string configuration = "";
329 // callback URL -  
330 string URL = ""; -  
331 // store message over state. 329 // store message over state.
332 string data = ""; 330 string data = "";
333   331  
334 // Notecard reading. 332 // Notecard reading.
335 key nQuery = NULL_KEY; 333 key nQuery = NULL_KEY;
336 integer nLine = 0; 334 integer nLine = 0;
337 list nList = []; 335 list nList = [];
338   336  
339 default { 337 default {
340 state_entry() { 338 state_entry() {
341 llOwnerSay("[Eval] Starting module..."); 339 llOwnerSay("[Eval] Starting module...");
342 llSetTimerEvent(10); 340 llSetTimerEvent(10);
343 } 341 }
344 link_message(integer sender, integer num, string message, key id) { 342 link_message(integer sender, integer num, string message, key id) {
345 if(id != "configuration") return; 343 if(id != "configuration") return;
346 llOwnerSay("[Eval] Got configuration..."); 344 llOwnerSay("[Eval] Got configuration...");
347 configuration = message; 345 configuration = message;
348 state listen_group; 346 state listen_group;
349 } 347 }
350 timer() { 348 timer() {
351 llOwnerSay("[Eval] Requesting configuration..."); 349 llOwnerSay("[Eval] Requesting configuration...");
352 llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); 350 llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY);
353 } 351 }
354 on_rez(integer num) { 352 on_rez(integer num) {
355 llResetScript(); 353 llResetScript();
356 } 354 }
357 changed(integer change) { 355 changed(integer change) {
358 if((change & CHANGED_INVENTORY) || 356 if((change & CHANGED_INVENTORY) ||
359 (change & CHANGED_REGION_START) || 357 (change & CHANGED_REGION_START) ||
360 (change & CHANGED_OWNER)) { 358 (change & CHANGED_OWNER)) {
361 llResetScript(); 359 llResetScript();
362 } 360 }
363 } 361 }
364 state_exit() { 362 state_exit() {
365 llSetTimerEvent(0); 363 llSetTimerEvent(0);
366 } 364 }
367 } 365 }
368   366  
369 state listen_group { 367 state listen_group {
370 state_entry() { 368 state_entry() {
371 // DEBUG 369 // DEBUG
372 llOwnerSay("[Eval] Waiting for group messages..."); 370 llOwnerSay("[Eval] Waiting for group messages...");
373 } 371 }
374 link_message(integer sender, integer num, string message, key id) { 372 link_message(integer sender, integer num, string message, key id) {
375 // We only care about notifications now. 373 // We only care about notifications now.
376 if(id != "notification") 374 if(id != "notification")
377 return; 375 return;
378 376  
379 // This script only processes group notifications. 377 // This script only processes group notifications.
380 if(wasKeyValueGet("type", message) != "group") 378 if(wasKeyValueGet("type", message) != "group" ||
-   379 (wasKeyValueGet("type", message) == "group" &&
-   380 wasURLUnescape(wasKeyValueGet("group", message)) !=
-   381 wasKeyValueGet("group", configuration)))
381 return; 382 return;
382 383  
383 // Get the sent message. 384 // Get the sent message.
384 data = wasURLUnescape( 385 data = wasURLUnescape(
385 wasKeyValueGet( 386 wasKeyValueGet(
386 "message", 387 "message",
387 message 388 message
388 ) 389 )
389 ); 390 );
390 391  
391 // Check if this is an eggdrop command. 392 // Check if this is an eggdrop command.
392 if(llGetSubString(data, 0, 0) != 393 if(llGetSubString(data, 0, 0) !=
393 wasKeyValueGet("command", configuration)) 394 wasKeyValueGet("command", configuration))
394 return; 395 return;
395 396  
396 // Check if the command matches the current module. 397 // Check if the command matches the current module.
397 list command = llParseString2List(data, [" "], []); 398 list command = llParseString2List(data, [" "], []);
398 if(llList2String(command, 0) != 399 if(llList2String(command, 0) !=
399 wasKeyValueGet("command", configuration) + "eval") 400 wasKeyValueGet("command", configuration) + "eval")
400 return; 401 return;
401 402  
402 // Remove command. 403 // Remove command.
403 command = llDeleteSubList(command, 0, 0); 404 command = llDeleteSubList(command, 0, 0);
404 405  
405 // Dump the rest of the message. 406 // Dump the rest of the message.
406 data = (string)wasPostfixEval( 407 data = (string)wasPostfixEval(
407 wasInfixToPostfix( 408 wasInfixToPostfix(
408 wasInfixTokenize( 409 wasInfixTokenize(
409 llDumpList2String( 410 llDumpList2String(
410 command, 411 command,
411 " " 412 " "
412 ) 413 )
413 ) 414 )
414 ) 415 )
415 ); 416 );
416 417  
417 state tell; 418 state tell;
418 } 419 }
419 on_rez(integer num) { 420 on_rez(integer num) {
420 llResetScript(); 421 llResetScript();
421 } 422 }
422 changed(integer change) { 423 changed(integer change) {
423 if((change & CHANGED_INVENTORY) || 424 if((change & CHANGED_INVENTORY) ||
424 (change & CHANGED_REGION_START) || 425 (change & CHANGED_REGION_START) ||
425 (change & CHANGED_OWNER)) { 426 (change & CHANGED_OWNER)) {
426 llResetScript(); 427 llResetScript();
427 } 428 }
428 } 429 }
429 } 430 }
430   431  
431 state tell { 432 state tell {
432 state_entry() { 433 state_entry() {
433 // DEBUG 434 // DEBUG
434 llOwnerSay("[Eval] Sending to group."); 435 llOwnerSay("[Eval] Sending to group.");
435 llInstantMessage( 436 llInstantMessage(
436 wasKeyValueGet( 437 wasKeyValueGet(
437 "corrade", 438 "corrade",
438 configuration 439 configuration
439 ), 440 ),
440 wasKeyValueEncode( 441 wasKeyValueEncode(
441 [ 442 [
442 "command", "tell", 443 "command", "tell",
443 "group", wasURLEscape( 444 "group", wasURLEscape(
444 wasKeyValueGet( 445 wasKeyValueGet(
445 "group", 446 "group",
446 configuration 447 configuration
447 ) 448 )
448 ), 449 ),
449 "password", wasURLEscape( 450 "password", wasURLEscape(
450 wasKeyValueGet( 451 wasKeyValueGet(
451 "password", 452 "password",
452 configuration 453 configuration
453 ) 454 )
454 ), 455 ),
455 "entity", "group", 456 "entity", "group",
456 "message", wasURLEscape(data) 457 "message", wasURLEscape(data)
457 ] 458 ]
458 ) 459 )
459 ); 460 );
460 state listen_group; 461 state listen_group;
461 } 462 }
462 } 463 }
463   464