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

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
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 // Help message for Corrade eggdrop. 5 // Help message for Corrade eggdrop.
6 // 6 //
7 /////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////
Line 15... Line 15...
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 = [];
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 {
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, ",");
Line 138... Line 138...
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 )
Line 161... Line 161...
161 ); 161 );
162 } 162 }
163   -  
164 // configuration data -  
165 string configuration = ""; 163  
166 // callback URL 164 // configuration data
Line 167... Line 165...
167 string URL = ""; 165 string configuration = "";
168 // store message over state. 166 // store message over state.
Line 185... Line 183...
185 } 183 }
186 on_rez(integer num) { 184 on_rez(integer num) {
187 llResetScript(); 185 llResetScript();
188 } 186 }
189 changed(integer change) { 187 changed(integer change) {
190 if((change & CHANGED_INVENTORY) || 188 if((change & CHANGED_INVENTORY) ||
191 (change & CHANGED_REGION_START) || 189 (change & CHANGED_REGION_START) ||
192 (change & CHANGED_OWNER)) { 190 (change & CHANGED_OWNER)) {
193 llResetScript(); 191 llResetScript();
194 } 192 }
195 } 193 }
196 state_exit() { 194 state_exit() {
Line 205... Line 203...
205 } 203 }
206 link_message(integer sender, integer num, string message, key id) { 204 link_message(integer sender, integer num, string message, key id) {
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;
210 208  
211 // This script only processes group notifications. 209 // This script only processes group notifications.
212 if(wasKeyValueGet("type", message) != "group") 210 if(wasKeyValueGet("type", message) != "group" ||
-   211 (wasKeyValueGet("type", message) == "group" &&
-   212 wasURLUnescape(wasKeyValueGet("group", message)) !=
-   213 wasKeyValueGet("group", configuration)))
213 return; 214 return;
214 215  
215 string firstname = wasURLUnescape( 216 string firstname = wasURLUnescape(
216 wasKeyValueGet( 217 wasKeyValueGet(
217 "firstname", 218 "firstname",
218 message 219 message
219 ) 220 )
220 ); 221 );
221 222  
222 string agent = (key)wasURLUnescape( 223 string agent = (key)wasURLUnescape(
223 wasKeyValueGet( 224 wasKeyValueGet(
224 "agent", 225 "agent",
225 message 226 message
226 ) 227 )
227 ); 228 );
228 229  
229 // Get the sent message. 230 // Get the sent message.
230 data = wasURLUnescape( 231 data = wasURLUnescape(
231 wasKeyValueGet( 232 wasKeyValueGet(
232 "message", 233 "message",
233 message 234 message
234 ) 235 )
235 ); 236 );
236 237  
237 // Check if this is an eggdrop command. 238 // Check if this is an eggdrop command.
238 if(llGetSubString(data, 0, 0) != 239 if(llGetSubString(data, 0, 0) !=
239 wasKeyValueGet("command", configuration)) 240 wasKeyValueGet("command", configuration))
240 return; 241 return;
241 242  
242 // Check if the command matches the current module. 243 // Check if the command matches the current module.
243 list command = llParseString2List(data, [" "], []); 244 list command = llParseString2List(data, [" "], []);
244 if(llList2String(command, 0) != 245 if(llList2String(command, 0) !=
245 wasKeyValueGet("command", configuration) + "help") 246 wasKeyValueGet("command", configuration) + "help")
246 return; 247 return;
247 248  
248 // Remove command. 249 // Remove command.
249 command = llDeleteSubList(command, 0, 0); 250 command = llDeleteSubList(command, 0, 0);
250 251  
251 if(llGetInventoryType(wasKeyValueGet("help card", configuration)) 252 if(llGetInventoryType(wasKeyValueGet("help card", configuration))
252 != INVENTORY_NOTECARD) { 253 != INVENTORY_NOTECARD) {
253 data = "Hmm. I have not notecard to hand out - contact my owner please?"; 254 data = "Hmm. I have not notecard to hand out - contact my owner please?";
254 state tell; 255 state tell;
255 } 256 }
256 257  
257 // Hand out the notecard. 258 // Hand out the notecard.
258 llGiveInventory(agent, 259 llGiveInventory(agent,
259 wasKeyValueGet("help card", configuration) 260 wasKeyValueGet("help card", configuration)
260 ); 261 );
261 262  
262 data = "Sent you a help notecard " + firstname + ". Please check your inventory."; 263 data = "Sent you a help notecard " + firstname + ". Please check your inventory.";
Line 263... Line 264...
263   264  
264 state tell; 265 state tell;
265 } 266 }
266 on_rez(integer num) { 267 on_rez(integer num) {
267 llResetScript(); 268 llResetScript();
268 } 269 }
269 changed(integer change) { 270 changed(integer change) {
270 if((change & CHANGED_INVENTORY) || 271 if((change & CHANGED_INVENTORY) ||
271 (change & CHANGED_REGION_START) || 272 (change & CHANGED_REGION_START) ||
272 (change & CHANGED_OWNER)) { 273 (change & CHANGED_OWNER)) {
273 llResetScript(); 274 llResetScript();
274 } 275 }
275 } 276 }
Line 279... Line 280...
279 state_entry() { 280 state_entry() {
280 // DEBUG 281 // DEBUG
281 llOwnerSay("[Help] Sending to group."); 282 llOwnerSay("[Help] Sending to group.");
282 llInstantMessage( 283 llInstantMessage(
283 wasKeyValueGet( 284 wasKeyValueGet(
284 "corrade", 285 "corrade",
285 configuration 286 configuration
286 ), 287 ),
287 wasKeyValueEncode( 288 wasKeyValueEncode(
288 [ 289 [
289 "command", "tell", 290 "command", "tell",
290 "group", wasURLEscape( 291 "group", wasURLEscape(
291 wasKeyValueGet( 292 wasKeyValueGet(
292 "group", 293 "group",
293 configuration 294 configuration
294 ) 295 )
295 ), 296 ),
296 "password", wasURLEscape( 297 "password", wasURLEscape(
297 wasKeyValueGet( 298 wasKeyValueGet(
298 "password", 299 "password",
299 configuration 300 configuration
300 ) 301 )
301 ), 302 ),
302 "entity", "group", 303 "entity", "group",
303 "message", wasURLEscape(data) 304 "message", wasURLEscape(data)