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

Subversion Repositories:
Rev:
Show entire fileRegard 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 // A module that sends the current Corrade version to group chat. 5 // A module that sends the current Corrade version to group chat.
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 160... Line 160...
160 ) 160 )
161 ); 161 );
162 } 162 }
Line 163... Line 163...
163   163  
164 /////////////////////////////////////////////////////////////////////////// 164 ///////////////////////////////////////////////////////////////////////////
165 // Copyright (C) 2017 Wizardry and Steamworks - License: CC BY 2.0 // 165 // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
166 /////////////////////////////////////////////////////////////////////////// 166 ///////////////////////////////////////////////////////////////////////////
167 list wasSetIntersect(list a, list b) { 167 list wasSetIntersect(list a, list b) {
168 if(llGetListLength(a) == 0) return []; 168 if(llGetListLength(a) == 0) return [];
169 string i = llList2String(a, 0); 169 string i = llList2String(a, 0);
Line 173... Line 173...
173 return i + wasSetIntersect(a, b); 173 return i + wasSetIntersect(a, b);
174 } 174 }
Line 175... Line 175...
175   175  
176 // configuration data 176 // configuration data
177 string configuration = ""; -  
178 // callback URL -  
179 string URL = ""; 177 string configuration = "";
180 // store message over state. 178 // store message over state.
Line 181... Line 179...
181 string data = ""; 179 string data = "";
182   180  
Line 219... Line 217...
219 // We only care about notifications now. 217 // We only care about notifications now.
220 if(id != "notification") 218 if(id != "notification")
221 return; 219 return;
Line 222... Line 220...
222 220  
223 // This script only processes group notifications. 221 // This script only processes group notifications.
-   222 if(wasKeyValueGet("type", message) != "group" ||
-   223 (wasKeyValueGet("type", message) == "group" &&
-   224 wasURLUnescape(wasKeyValueGet("group", message)) !=
224 if(wasKeyValueGet("type", message) != "group") 225 wasKeyValueGet("group", configuration)))
Line 225... Line 226...
225 return; 226 return;
226 227  
227 // Get the sent message. 228 // Get the sent message.
Line 244... Line 245...
244 return; 245 return;
Line 245... Line 246...
245 246  
246 // Remove command. 247 // Remove command.
Line 247... Line 248...
247 command = llDeleteSubList(command, 0, 0); 248 command = llDeleteSubList(command, 0, 0);
248   -  
249 // Get an URL. -  
250 state url; -  
251 } -  
252 on_rez(integer num) { -  
253 llResetScript(); -  
254 } -  
255 changed(integer change) { -  
256 if((change & CHANGED_INVENTORY) || -  
257 (change & CHANGED_REGION_START) || -  
258 (change & CHANGED_OWNER)) { -  
259 llResetScript(); -  
260 } -  
261 } -  
262 } -  
263   -  
264 state url { -  
265 state_entry() { -  
266 // DEBUG -  
267 llOwnerSay("[Version] Requesting URL..."); -  
268 llRequestURL(); -  
269 } -  
270 http_request(key id, string method, string body) { -  
271 if(method != URL_REQUEST_GRANTED) return; -  
272 URL = body; -  
273 // DEBUG 249  
274 llOwnerSay("[Version] Got URL..."); 250 // Get version.
275 state version; 251 state version;
276 } 252 }
277 on_rez(integer num) { 253 on_rez(integer num) {
Line 308... Line 284...
308 wasKeyValueGet( 284 wasKeyValueGet(
309 "password", 285 "password",
310 configuration 286 configuration
311 ) 287 )
312 ), 288 ),
313 "callback", wasURLEscape(URL) 289 "callback", wasURLEscape(
-   290 wasKeyValueGet(
-   291 "URL",
-   292 configuration
-   293 )
-   294 )
314 ] 295 ]
315 ) 296 )
316 ); 297 );
317 llSetTimerEvent(60); 298 llSetTimerEvent(60);
318 } 299 }
319 http_request(key id, string method, string body) { 300 link_message(integer sender, integer num, string body, key id) {
320 llHTTPResponse(id, 200, "OK"); 301 // Only process callbacks for the database command.
321 llReleaseURL(URL); -  
322 if(wasKeyValueGet("command", body) != "version" || 302 if(id != "callback" || wasKeyValueGet("command", body) != "version")
-   303 return;
-   304  
323 wasKeyValueGet("success", body) != "True") { 305 if(wasKeyValueGet("success", body) != "True") {
324 // DEBUG 306 // DEBUG
325 llOwnerSay("[Version] Unable to get version: " + 307 llOwnerSay("[Version] Unable to get version: " +
326 wasURLUnescape( 308 wasURLUnescape(
327 wasKeyValueGet("error", body) 309 wasKeyValueGet("error", body)
328 ) 310 )
Line 333... Line 315...
333 data = "I'm a " + wasKeyValueGet("data", body); 315 data = "I'm a " + wasKeyValueGet("data", body);
Line 334... Line 316...
334 316  
335 state tell; 317 state tell;
336 } 318 }
337 timer() { -  
338 llReleaseURL(URL); 319 timer() {
339 state listen_group; 320 state listen_group;
340 } 321 }
341 on_rez(integer num) { 322 on_rez(integer num) {
342 llResetScript(); 323 llResetScript();