corrade-lsl-templates – Diff between revs 29 and 31
?pathlinks?
Rev 29 | Rev 31 | |||
---|---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // |
4 | // |
|
5 | // This script will make Corrade scan for primitives in the vicinity and |
5 | // This script will make Corrade scan for primitives in the vicinity and |
|
6 | // will then offer a dialog for you to pick which primitive to touch. |
6 | // will then offer a dialog for you to pick which primitive to touch. |
|
7 | // |
7 | // |
|
8 | // For more information on Corrade, please see: |
8 | // For more information on Corrade, please see: |
|
9 | // http://grimore.org/secondlife/scripted_agents/corrade |
9 | // http://grimore.org/secondlife/scripted_agents/corrade |
|
10 | // |
10 | // |
|
11 | /////////////////////////////////////////////////////////////////////////// |
11 | /////////////////////////////////////////////////////////////////////////// |
|
12 | |
12 | |
|
13 | /////////////////////////////////////////////////////////////////////////// |
13 | /////////////////////////////////////////////////////////////////////////// |
|
14 | // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // |
14 | // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // |
|
15 | /////////////////////////////////////////////////////////////////////////// |
15 | /////////////////////////////////////////////////////////////////////////// |
|
16 | string wasKeyValueGet(string k, string data) { |
16 | string wasKeyValueGet(string k, string data) { |
|
17 | if(llStringLength(data) == 0) return ""; |
17 | if(llStringLength(data) == 0) return ""; |
|
18 | if(llStringLength(k) == 0) return ""; |
18 | if(llStringLength(k) == 0) return ""; |
|
19 | list a = llParseString2List(data, ["&", "="], []); |
19 | list a = llParseString2List(data, ["&", "="], []); |
|
20 | integer i = llListFindList(a, [ k ]); |
20 | integer i = llListFindList(a, [ k ]); |
|
21 | if(i != -1) return llList2String(a, i+1); |
21 | if(i != -1) return llList2String(a, i+1); |
|
22 | return ""; |
22 | return ""; |
|
23 | } |
23 | } |
|
24 | |
24 | |
|
25 | /////////////////////////////////////////////////////////////////////////// |
25 | /////////////////////////////////////////////////////////////////////////// |
|
26 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
26 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
|
27 | /////////////////////////////////////////////////////////////////////////// |
27 | /////////////////////////////////////////////////////////////////////////// |
|
28 | string wasKeyValueEncode(list data) { |
28 | string wasKeyValueEncode(list data) { |
|
29 | list k = llList2ListStrided(data, 0, -1, 2); |
29 | list k = llList2ListStrided(data, 0, -1, 2); |
|
30 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
30 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
|
31 | data = []; |
31 | data = []; |
|
32 | do { |
32 | do { |
|
33 | data += llList2String(k, 0) + "=" + llList2String(v, 0); |
33 | data += llList2String(k, 0) + "=" + llList2String(v, 0); |
|
34 | k = llDeleteSubList(k, 0, 0); |
34 | k = llDeleteSubList(k, 0, 0); |
|
35 | v = llDeleteSubList(v, 0, 0); |
35 | v = llDeleteSubList(v, 0, 0); |
|
36 | } while(llGetListLength(k) != 0); |
36 | } while(llGetListLength(k) != 0); |
|
37 | return llDumpList2String(data, "&"); |
37 | return llDumpList2String(data, "&"); |
|
38 | } |
38 | } |
|
39 | |
39 | |
|
40 | /////////////////////////////////////////////////////////////////////////// |
40 | /////////////////////////////////////////////////////////////////////////// |
|
41 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
41 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
|
42 | /////////////////////////////////////////////////////////////////////////// |
42 | /////////////////////////////////////////////////////////////////////////// |
|
43 | // http://was.fm/secondlife/wanderer |
43 | // http://was.fm/secondlife/wanderer |
|
44 | vector wasCirclePoint(float radius) { |
44 | vector wasCirclePoint(float radius) { |
|
45 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
45 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
46 | float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
46 | float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
47 | if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
47 | if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
|
48 | return <x, y, 0>; |
48 | return <x, y, 0>; |
|
49 | return wasCirclePoint(radius); |
49 | return wasCirclePoint(radius); |
|
50 | } |
50 | } |
|
51 | |
51 | |
|
52 | /////////////////////////////////////////////////////////////////////////// |
52 | /////////////////////////////////////////////////////////////////////////// |
|
53 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
53 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
54 | /////////////////////////////////////////////////////////////////////////// |
54 | /////////////////////////////////////////////////////////////////////////// |
|
55 | // escapes a string in conformance with RFC1738 |
55 | // escapes a string in conformance with RFC1738 |
|
56 | string wasURLEscape(string i) { |
56 | string wasURLEscape(string i) { |
|
57 | string o = ""; |
57 | string o = ""; |
|
58 | do { |
58 | do { |
|
59 | string c = llGetSubString(i, 0, 0); |
59 | string c = llGetSubString(i, 0, 0); |
|
60 | i = llDeleteSubString(i, 0, 0); |
60 | i = llDeleteSubString(i, 0, 0); |
|
61 | if(c == "") jump continue; |
61 | if(c == "") jump continue; |
|
62 | if(c == " ") { |
62 | if(c == " ") { |
|
63 | o += "+"; |
63 | o += "+"; |
|
64 | jump continue; |
64 | jump continue; |
|
65 | } |
65 | } |
|
66 | if(c == "\n") { |
66 | if(c == "\n") { |
|
67 | o += "%0D" + llEscapeURL(c); |
67 | o += "%0D" + llEscapeURL(c); |
|
68 | jump continue; |
68 | jump continue; |
|
69 | } |
69 | } |
|
70 | o += llEscapeURL(c); |
70 | o += llEscapeURL(c); |
|
71 | @continue; |
71 | @continue; |
|
72 | } while(i != ""); |
72 | } while(i != ""); |
|
73 | return o; |
73 | return o; |
|
74 | } |
74 | } |
|
75 | |
75 | |
|
76 | /////////////////////////////////////////////////////////////////////////// |
76 | /////////////////////////////////////////////////////////////////////////// |
|
77 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
77 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
78 | /////////////////////////////////////////////////////////////////////////// |
78 | /////////////////////////////////////////////////////////////////////////// |
|
79 | list wasCSVToList(string csv) { |
79 | list wasCSVToList(string csv) { |
|
80 | list l = []; |
80 | list l = []; |
|
81 | list s = []; |
81 | list s = []; |
|
82 | string m = ""; |
82 | string m = ""; |
|
83 | do { |
83 | do { |
|
84 | string a = llGetSubString(csv, 0, 0); |
84 | string a = llGetSubString(csv, 0, 0); |
|
85 | csv = llDeleteSubString(csv, 0, 0); |
85 | csv = llDeleteSubString(csv, 0, 0); |
|
86 | if(a == ",") { |
86 | if(a == ",") { |
|
87 | if(llList2String(s, -1) != "\"") { |
87 | if(llList2String(s, -1) != "\"") { |
|
88 | l += m; |
88 | l += m; |
|
89 | m = ""; |
89 | m = ""; |
|
90 | jump continue; |
90 | jump continue; |
|
91 | } |
91 | } |
|
92 | m += a; |
92 | m += a; |
|
93 | jump continue; |
93 | jump continue; |
|
94 | } |
94 | } |
|
95 | if(a == "\"" && llGetSubString(csv, 0, 0) == a) { |
95 | if(a == "\"" && llGetSubString(csv, 0, 0) == a) { |
|
96 | m += a; |
96 | m += a; |
|
97 | csv = llDeleteSubString(csv, 0, 0); |
97 | csv = llDeleteSubString(csv, 0, 0); |
|
98 | jump continue; |
98 | jump continue; |
|
99 | } |
99 | } |
|
100 | if(a == "\"") { |
100 | if(a == "\"") { |
|
101 | if(llList2String(s, -1) != a) { |
101 | if(llList2String(s, -1) != a) { |
|
102 | s += a; |
102 | s += a; |
|
103 | jump continue; |
103 | jump continue; |
|
104 | } |
104 | } |
|
105 | s = llDeleteSubList(s, -1, -1); |
105 | s = llDeleteSubList(s, -1, -1); |
|
106 | jump continue; |
106 | jump continue; |
|
107 | } |
107 | } |
|
108 | m += a; |
108 | m += a; |
|
109 | @continue; |
109 | @continue; |
|
110 | } while(csv != ""); |
110 | } while(csv != ""); |
|
111 | // postcondition: length(s) = 0 |
111 | // postcondition: length(s) = 0 |
|
112 | return l + m; |
112 | return l + m; |
|
113 | } |
113 | } |
|
114 | |
114 | |
|
115 | /////////////////////////////////////////////////////////////////////////// |
115 | /////////////////////////////////////////////////////////////////////////// |
|
116 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
116 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
117 | /////////////////////////////////////////////////////////////////////////// |
117 | /////////////////////////////////////////////////////////////////////////// |
|
118 | string wasListToCSV(list l) { |
118 | string wasListToCSV(list l) { |
|
119 | list v = []; |
119 | list v = []; |
|
120 | do { |
120 | do { |
|
121 | string a = llDumpList2String( |
121 | string a = llDumpList2String( |
|
122 | llParseStringKeepNulls( |
122 | llParseStringKeepNulls( |
|
123 | llList2String( |
123 | llList2String( |
|
124 | l, |
124 | l, |
|
125 | 0 |
125 | 0 |
|
126 | ), |
126 | ), |
|
127 | ["\""], |
127 | ["\""], |
|
128 | [] |
128 | [] |
|
129 | ), |
129 | ), |
|
130 | "\"\"" |
130 | "\"\"" |
|
131 | ); |
131 | ); |
|
132 | if(llParseStringKeepNulls( |
132 | if(llParseStringKeepNulls( |
|
133 | a, |
133 | a, |
|
134 | [" ", ",", "\n", "\""], [] |
134 | [" ", ",", "\n", "\""], [] |
|
135 | ) != |
135 | ) != |
|
136 | (list) a |
136 | (list) a |
|
137 | ) a = "\"" + a + "\""; |
137 | ) a = "\"" + a + "\""; |
|
138 | v += a; |
138 | v += a; |
|
139 | l = llDeleteSubList(l, 0, 0); |
139 | l = llDeleteSubList(l, 0, 0); |
|
140 | } while(l != []); |
140 | } while(l != []); |
|
141 | return llDumpList2String(v, ","); |
141 | return llDumpList2String(v, ","); |
|
142 | } |
142 | } |
|
143 | |
143 | |
|
144 | /////////////////////////////////////////////////////////////////////////// |
144 | /////////////////////////////////////////////////////////////////////////// |
|
145 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
145 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
146 | /////////////////////////////////////////////////////////////////////////// |
146 | /////////////////////////////////////////////////////////////////////////// |
|
147 | // unescapes a string in conformance with RFC1738 |
147 | // unescapes a string in conformance with RFC1738 |
|
148 | string wasURLUnescape(string i) { |
148 | string wasURLUnescape(string i) { |
|
149 | return llUnescapeURL( |
149 | return llUnescapeURL( |
|
150 | llDumpList2String( |
150 | llDumpList2String( |
|
151 | llParseString2List( |
151 | llParseString2List( |
|
152 | llDumpList2String( |
152 | llDumpList2String( |
|
153 | llParseString2List( |
153 | llParseString2List( |
|
154 | i, |
154 | i, |
|
155 | ["+"], |
155 | ["+"], |
|
156 | [] |
156 | [] |
|
157 | ), |
157 | ), |
|
158 | " " |
158 | " " |
|
159 | ), |
159 | ), |
|
160 | ["%0D%0A"], |
160 | ["%0D%0A"], |
|
161 | [] |
161 | [] |
|
162 | ), |
162 | ), |
|
163 | "\n" |
163 | "\n" |
|
164 | ) |
164 | ) |
|
165 | ); |
165 | ); |
|
166 | } |
166 | } |
|
167 | |
167 | |
|
168 | /////////////////////////////////////////////////////////////////////////// |
168 | /////////////////////////////////////////////////////////////////////////// |
|
169 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
169 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
|
170 | /////////////////////////////////////////////////////////////////////////// |
170 | /////////////////////////////////////////////////////////////////////////// |
|
171 | integer wasMenuIndex = 0; |
171 | integer wasMenuIndex = 0; |
|
172 | list wasDialogMenu(list input, list actions, string direction) { |
172 | list wasDialogMenu(list input, list actions, string direction) { |
|
173 | integer cut = 11-wasListCountExclude(actions, [""]); |
173 | integer cut = 11-wasListCountExclude(actions, [""]); |
|
174 | if(direction == ">" && (wasMenuIndex+1)*cut+wasMenuIndex+1 < llGetListLength(input)) { |
174 | if(direction == ">" && (wasMenuIndex+1)*cut+wasMenuIndex+1 < llGetListLength(input)) { |
|
175 | ++wasMenuIndex; |
175 | ++wasMenuIndex; |
|
176 | jump slice; |
176 | jump slice; |
|
177 | } |
177 | } |
|
178 | if(direction == "<" && wasMenuIndex-1 >= 0) { |
178 | if(direction == "<" && wasMenuIndex-1 >= 0) { |
|
179 | --wasMenuIndex; |
179 | --wasMenuIndex; |
|
180 | jump slice; |
180 | jump slice; |
|
181 | } |
181 | } |
|
182 | @slice; |
182 | @slice; |
|
183 | integer multiple = wasMenuIndex*cut; |
183 | integer multiple = wasMenuIndex*cut; |
|
184 | input = llList2List(input, multiple+wasMenuIndex, multiple+cut+wasMenuIndex); |
184 | input = llList2List(input, multiple+wasMenuIndex, multiple+cut+wasMenuIndex); |
|
185 | input = wasListMerge(input, actions, ""); |
185 | input = wasListMerge(input, actions, ""); |
|
186 | return input; |
186 | return input; |
|
187 | } |
187 | } |
|
188 | |
188 | |
|
189 | /////////////////////////////////////////////////////////////////////////// |
189 | /////////////////////////////////////////////////////////////////////////// |
|
190 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
190 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
|
191 | /////////////////////////////////////////////////////////////////////////// |
191 | /////////////////////////////////////////////////////////////////////////// |
|
192 | integer wasListCountExclude(list input, list exclude) { |
192 | integer wasListCountExclude(list input, list exclude) { |
|
193 | if(llGetListLength(input) == 0) return 0; |
193 | if(llGetListLength(input) == 0) return 0; |
|
194 | if(llListFindList(exclude, (list)llList2String(input, 0)) == -1) |
194 | if(llListFindList(exclude, (list)llList2String(input, 0)) == -1) |
|
195 | return 1 + wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); |
195 | return 1 + wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); |
|
196 | return wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); |
196 | return wasListCountExclude(llDeleteSubList(input, 0, 0), exclude); |
|
197 | } |
197 | } |
|
198 | |
198 | |
|
199 | /////////////////////////////////////////////////////////////////////////// |
199 | /////////////////////////////////////////////////////////////////////////// |
|
200 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
200 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
|
201 | /////////////////////////////////////////////////////////////////////////// |
201 | /////////////////////////////////////////////////////////////////////////// |
|
202 | list wasListMerge(list l, list m, string merge) { |
202 | list wasListMerge(list l, list m, string merge) { |
|
203 | if(llGetListLength(l) == 0 && llGetListLength(m) == 0) return []; |
203 | if(llGetListLength(l) == 0 && llGetListLength(m) == 0) return []; |
|
204 | string a = llList2String(m, 0); |
204 | string a = llList2String(m, 0); |
|
205 | if(a != merge) return [ a ] + wasListMerge(l, llDeleteSubList(m, 0, 0), merge); |
205 | if(a != merge) return [ a ] + wasListMerge(l, llDeleteSubList(m, 0, 0), merge); |
|
206 | return [ llList2String(l, 0) ] + wasListMerge(llDeleteSubList(l, 0, 0), llDeleteSubList(m, 0, 0), merge); |
206 | return [ llList2String(l, 0) ] + wasListMerge(llDeleteSubList(l, 0, 0), llDeleteSubList(m, 0, 0), merge); |
|
207 | } |
207 | } |
|
208 | |
208 | |
|
209 | // configuration data |
209 | // configuration data |
|
210 | string configuration = ""; |
210 | string configuration = ""; |
|
211 | // callback URL |
211 | // callback URL |
|
212 | string callback = ""; |
212 | string callback = ""; |
|
213 | // scanned primitives |
213 | // scanned primitives |
|
214 | list names = []; |
214 | list names = []; |
|
215 | list UUIDs = []; |
215 | list UUIDs = []; |
|
216 | // temporary list for button name normalization |
216 | // temporary list for button name normalization |
|
217 | list menu = []; |
217 | list menu = []; |
|
218 | integer select = -1; |
218 | integer select = -1; |
|
219 | |
219 | |
|
220 | default { |
220 | default { |
|
221 | state_entry() { |
221 | state_entry() { |
|
222 | llSetTimerEvent(1); |
222 | llSetTimerEvent(1); |
|
223 | } |
223 | } |
|
224 | link_message(integer sender, integer num, string message, key id) { |
224 | link_message(integer sender, integer num, string message, key id) { |
|
225 | if(sender != 1 || id != "configuration") return; |
225 | if(sender != 1 || id != "configuration") return; |
|
226 | configuration = message; |
226 | configuration = message; |
|
227 | state off; |
227 | state off; |
|
228 | } |
228 | } |
|
229 | timer() { |
229 | timer() { |
|
230 | llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY); |
230 | llMessageLinked(LINK_ROOT, 0, "configuration", NULL_KEY); |
|
231 | } |
231 | } |
|
232 | attach(key id) { |
232 | attach(key id) { |
|
233 | llResetScript(); |
233 | llResetScript(); |
|
234 | } |
234 | } |
|
235 | on_rez(integer num) { |
235 | on_rez(integer num) { |
|
236 | llResetScript(); |
236 | llResetScript(); |
|
237 | } |
237 | } |
|
238 | changed(integer change) { |
238 | changed(integer change) { |
|
239 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
239 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
240 | llResetScript(); |
240 | llResetScript(); |
|
241 | } |
241 | } |
|
242 | } |
242 | } |
|
243 | state_exit() { |
243 | state_exit() { |
|
244 | llSetTimerEvent(0); |
244 | llSetTimerEvent(0); |
|
245 | } |
245 | } |
|
246 | } |
246 | } |
|
247 | |
247 | |
|
248 | state off { |
248 | state off { |
|
249 | state_entry() { |
249 | state_entry() { |
|
250 | llSetColor(<.5,0,0>, ALL_SIDES); |
250 | llSetColor(<.5,0,0>, ALL_SIDES); |
|
251 | } |
251 | } |
|
252 | touch_end(integer num) { |
252 | touch_end(integer num) { |
|
253 | state on; |
253 | state on; |
|
254 | } |
254 | } |
|
255 | attach(key id) { |
255 | attach(key id) { |
|
256 | llResetScript(); |
256 | llResetScript(); |
|
257 | } |
257 | } |
|
258 | on_rez(integer num) { |
258 | on_rez(integer num) { |
|
259 | llResetScript(); |
259 | llResetScript(); |
|
260 | } |
260 | } |
|
261 | changed(integer change) { |
261 | changed(integer change) { |
|
262 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
262 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
263 | llResetScript(); |
263 | llResetScript(); |
|
264 | } |
264 | } |
|
265 | } |
265 | } |
|
266 | } |
266 | } |
|
267 | |
267 | |
|
268 | state on { |
268 | state on { |
|
269 | state_entry() { |
269 | state_entry() { |
|
270 | llSetColor(<0,.5,0>, ALL_SIDES); |
270 | llSetColor(<0,.5,0>, ALL_SIDES); |
|
271 | state url; |
271 | state url; |
|
272 | } |
272 | } |
|
273 | attach(key id) { |
273 | attach(key id) { |
|
274 | llResetScript(); |
274 | llResetScript(); |
|
275 | } |
275 | } |
|
276 | on_rez(integer num) { |
276 | on_rez(integer num) { |
|
277 | llResetScript(); |
277 | llResetScript(); |
|
278 | } |
278 | } |
|
279 | changed(integer change) { |
279 | changed(integer change) { |
|
280 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
280 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
281 | llResetScript(); |
281 | llResetScript(); |
|
282 | } |
282 | } |
|
283 | } |
283 | } |
|
284 | } |
284 | } |
|
285 | |
285 | |
|
286 | state url { |
286 | state url { |
|
287 | state_entry() { |
287 | state_entry() { |
|
288 | // DEBUG |
288 | // DEBUG |
|
289 | llOwnerSay("Requesting URL..."); |
289 | llOwnerSay("Requesting URL..."); |
|
290 | llRequestURL(); |
290 | llRequestURL(); |
|
291 | } |
291 | } |
|
292 | touch_end(integer num) { |
292 | touch_end(integer num) { |
|
293 | llSetColor(<.5,0,0>, ALL_SIDES); |
293 | llSetColor(<.5,0,0>, ALL_SIDES); |
|
294 | llResetScript(); |
294 | llResetScript(); |
|
295 | } |
295 | } |
|
296 | http_request(key id, string method, string body) { |
296 | http_request(key id, string method, string body) { |
|
297 | if(method != URL_REQUEST_GRANTED) return; |
297 | if(method != URL_REQUEST_GRANTED) return; |
|
298 | callback = body; |
298 | callback = body; |
|
299 | // DEBUG |
299 | // DEBUG |
|
300 | llOwnerSay("Got URL..."); |
300 | llOwnerSay("Got URL..."); |
|
301 | state scan; |
301 | state scan; |
|
302 | } |
302 | } |
|
303 | attach(key id) { |
303 | attach(key id) { |
|
304 | llResetScript(); |
304 | llResetScript(); |
|
305 | } |
305 | } |
|
306 | on_rez(integer num) { |
306 | on_rez(integer num) { |
|
307 | llResetScript(); |
307 | llResetScript(); |
|
308 | } |
308 | } |
|
309 | changed(integer change) { |
309 | changed(integer change) { |
|
310 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
310 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
311 | llResetScript(); |
311 | llResetScript(); |
|
312 | } |
312 | } |
|
313 | } |
313 | } |
|
314 | } |
314 | } |
|
315 | |
315 | |
|
316 | state scan { |
316 | state scan { |
|
317 | state_entry() { |
317 | state_entry() { |
|
318 | // DEBUG |
318 | // DEBUG |
|
319 | llOwnerSay("Getting objects..."); |
319 | llOwnerSay("Getting primitives..."); |
|
320 | llInstantMessage( |
320 | llInstantMessage( |
|
321 | wasKeyValueGet( |
321 | wasKeyValueGet( |
|
322 | "corrade", |
322 | "corrade", |
|
323 | configuration |
323 | configuration |
|
324 | ), |
324 | ), |
|
325 | wasKeyValueEncode( |
325 | wasKeyValueEncode( |
|
326 | [ |
326 | [ |
|
327 | "command", "getobjectsdata", |
327 | "command", "getprimitivesdata", |
|
328 | "group", wasURLEscape( |
328 | "group", wasURLEscape( |
|
329 | wasKeyValueGet( |
329 | wasKeyValueGet( |
|
330 | "group", |
330 | "group", |
|
331 | configuration |
331 | configuration |
|
332 | ) |
332 | ) |
|
333 | ), |
333 | ), |
|
334 | "password", wasURLEscape( |
334 | "password", wasURLEscape( |
|
335 | wasKeyValueGet( |
335 | wasKeyValueGet( |
|
336 | "password", |
336 | "password", |
|
337 | configuration |
337 | configuration |
|
338 | ) |
338 | ) |
|
339 | ), |
339 | ), |
|
340 | "entity", "world", |
340 | "entity", "world", |
|
341 | "range", wasURLEscape( |
341 | "range", wasURLEscape( |
|
342 | wasKeyValueGet( |
342 | wasKeyValueGet( |
|
343 | "radar", |
343 | "radar", |
|
344 | configuration |
344 | configuration |
|
345 | ) |
345 | ) |
|
346 | ), |
346 | ), |
|
347 | "data", wasListToCSV( |
347 | "data", wasListToCSV( |
|
348 | [ |
348 | [ |
|
349 | "Properties.Name", |
349 | "Properties.Name", |
|
350 | "ID" |
350 | "ID" |
|
351 | ] |
351 | ] |
|
352 | ), |
352 | ), |
|
353 | "sift", wasListToCSV( |
353 | "sift", wasListToCSV( |
|
354 | [ |
354 | [ |
|
355 | "take", 32 |
355 | "take", 32 |
|
356 | ] |
356 | ] |
|
357 | ), |
357 | ), |
|
358 | "callback", wasURLEscape(callback) |
358 | "callback", wasURLEscape(callback) |
|
359 | ] |
359 | ] |
|
360 | ) |
360 | ) |
|
361 | ); |
361 | ); |
|
362 | } |
362 | } |
|
363 | touch_end(integer num) { |
363 | touch_end(integer num) { |
|
364 | llSetColor(<.5,0,0>, ALL_SIDES); |
364 | llSetColor(<.5,0,0>, ALL_SIDES); |
|
365 | llResetScript(); |
365 | llResetScript(); |
|
366 | } |
366 | } |
|
367 | http_request(key id, string method, string body) { |
367 | http_request(key id, string method, string body) { |
|
368 | llHTTPResponse(id, 200, "OK"); |
368 | llHTTPResponse(id, 200, "OK"); |
|
369 | if(wasKeyValueGet("command", body) != "getobjectsdata" || |
369 | if(wasKeyValueGet("command", body) != "getprimitivesdata" || |
|
370 | wasKeyValueGet("success", body) != "True") { |
370 | wasKeyValueGet("success", body) != "True") { |
|
371 | // DEBUG |
371 | // DEBUG |
|
372 | llOwnerSay("Unable to query primitives data: " + |
372 | llOwnerSay("Unable to query primitives data: " + |
|
373 | wasURLUnescape( |
373 | wasURLUnescape( |
|
374 | wasKeyValueGet( |
374 | wasKeyValueGet( |
|
375 | "error", |
375 | "error", |
|
376 | body |
376 | body |
|
377 | ) |
377 | ) |
|
378 | ) |
378 | ) |
|
379 | ); |
379 | ); |
|
380 | llResetScript(); |
380 | llResetScript(); |
|
381 | } |
381 | } |
|
382 | string dataKey = wasURLUnescape( |
382 | string dataKey = wasURLUnescape( |
|
383 | wasKeyValueGet( |
383 | wasKeyValueGet( |
|
384 | "data", |
384 | "data", |
|
385 | body |
385 | body |
|
386 | ) |
386 | ) |
|
387 | ); |
387 | ); |
|
388 | if(dataKey == "") { |
388 | if(dataKey == "") { |
|
389 | // DEBUG |
389 | // DEBUG |
|
390 | llOwnerSay("No data for scanned primitives..."); |
390 | llOwnerSay("No data for scanned primitives..."); |
|
391 | llResetScript(); |
391 | llResetScript(); |
|
392 | } |
392 | } |
|
393 | list data = wasCSVToList(dataKey); |
393 | list data = wasCSVToList(dataKey); |
|
394 | // Copy the names and UUIDs of the primitives. |
394 | // Copy the names and UUIDs of the primitives. |
|
395 | names = []; |
395 | names = []; |
|
396 | UUIDs = []; |
396 | UUIDs = []; |
|
397 | do { |
397 | do { |
|
398 | string v = llList2String(data, -1); |
398 | string v = llList2String(data, -1); |
|
399 | data = llDeleteSubList(data, -1, -1); |
399 | data = llDeleteSubList(data, -1, -1); |
|
400 | string k = llList2String(data, -1); |
400 | string k = llList2String(data, -1); |
|
401 | data = llDeleteSubList(data, -1, -1); |
401 | data = llDeleteSubList(data, -1, -1); |
|
402 | if(k == "Properties.Name") { |
402 | if(k == "Properties.Name") { |
|
403 | names += v; |
403 | names += v; |
|
404 | jump continue; |
404 | jump continue; |
|
405 | } |
405 | } |
|
406 | UUIDs += (key)v; |
406 | UUIDs += (key)v; |
|
407 | @continue; |
407 | @continue; |
|
408 | } while(llGetListLength(data)); |
408 | } while(llGetListLength(data)); |
|
409 | state choose; |
409 | state choose; |
|
410 | } |
410 | } |
|
411 | attach(key id) { |
411 | attach(key id) { |
|
412 | llResetScript(); |
412 | llResetScript(); |
|
413 | } |
413 | } |
|
414 | on_rez(integer num) { |
414 | on_rez(integer num) { |
|
415 | llResetScript(); |
415 | llResetScript(); |
|
416 | } |
416 | } |
|
417 | changed(integer change) { |
417 | changed(integer change) { |
|
418 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
418 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
419 | llResetScript(); |
419 | llResetScript(); |
|
420 | } |
420 | } |
|
421 | } |
421 | } |
|
422 | state_exit() { |
422 | state_exit() { |
|
423 | llSetTimerEvent(0); |
423 | llSetTimerEvent(0); |
|
424 | } |
424 | } |
|
425 | } |
425 | } |
|
426 | |
426 | |
|
427 | state choose { |
427 | state choose { |
|
428 | state_entry() { |
428 | state_entry() { |
|
429 | // DEBUG |
429 | // DEBUG |
|
430 | llOwnerSay("Sending menu..."); |
430 | llOwnerSay("Sending menu..."); |
|
431 | menu = []; |
431 | menu = []; |
|
432 | integer i = 0; |
432 | integer i = 0; |
|
433 | do { |
433 | do { |
|
434 | menu += llGetSubString(llList2String(names, i), 0, 23); |
434 | menu += llGetSubString(llList2String(names, i), 0, 23); |
|
435 | } while(++i < llGetListLength(names)); |
435 | } while(++i < llGetListLength(names)); |
|
436 | llListen(-10, "", llGetOwner(), ""); |
436 | llListen(-10, "", llGetOwner(), ""); |
|
437 | llDialog(llGetOwner(), "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ""), -10); |
437 | llDialog(llGetOwner(), "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ""), -10); |
|
438 | llSetTimerEvent(60); |
438 | llSetTimerEvent(60); |
|
439 | } |
439 | } |
|
440 | touch_end(integer num) { |
440 | touch_end(integer num) { |
|
441 | llSetColor(<.5,0,0>, ALL_SIDES); |
441 | llSetColor(<.5,0,0>, ALL_SIDES); |
|
442 | llResetScript(); |
442 | llResetScript(); |
|
443 | } |
443 | } |
|
444 | listen(integer channel, string name, key id, string message) { |
444 | listen(integer channel, string name, key id, string message) { |
|
445 | if(message == "⟵ Back") { |
445 | if(message == "⟵ Back") { |
|
446 | llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], "<"), -10); |
446 | llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], "<"), -10); |
|
447 | return; |
447 | return; |
|
448 | } |
448 | } |
|
449 | if(message == "Next ⟶") { |
449 | if(message == "Next ⟶") { |
|
450 | llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ">"), -10); |
450 | llDialog(id, "\nPlease choose a primitive for Corrade to sit on from the list below:\n", wasDialogMenu(menu, ["⟵ Back", "", "Next ⟶"], ">"), -10); |
|
451 | return; |
451 | return; |
|
452 | } |
452 | } |
|
453 | integer i = llGetListLength(menu) - 1; |
453 | integer i = llGetListLength(menu) - 1; |
|
454 | do { |
454 | do { |
|
455 | string v = llList2String(menu, i); |
455 | string v = llList2String(menu, i); |
|
456 | if(llSubStringIndex(v, message) != -1) |
456 | if(llSubStringIndex(v, message) != -1) |
|
457 | jump sit; |
457 | jump sit; |
|
458 | } while(--i > -1); |
458 | } while(--i > -1); |
|
459 | // GC |
459 | // GC |
|
460 | menu = []; |
460 | menu = []; |
|
461 | // DEBUG |
461 | // DEBUG |
|
462 | llOwnerSay("Invalid menu item selected..."); |
462 | llOwnerSay("Invalid menu item selected..."); |
|
463 | llResetScript(); |
463 | llResetScript(); |
|
464 | @sit; |
464 | @sit; |
|
465 | // GC |
465 | // GC |
|
466 | menu = []; |
466 | menu = []; |
|
467 | select = i; |
467 | select = i; |
|
468 | // Got a menu item so bind to permission notifications and sit. |
468 | // Got a menu item so bind to permission notifications and sit. |
|
469 | state touch_primitive; |
469 | state touch_primitive; |
|
470 | |
470 | |
|
471 | } |
471 | } |
|
472 | timer() { |
472 | timer() { |
|
473 | // DEBUG |
473 | // DEBUG |
|
474 | llOwnerSay("Dialog menu timeout..."); |
474 | llOwnerSay("Dialog menu timeout..."); |
|
475 | llResetScript(); |
475 | llResetScript(); |
|
476 | } |
476 | } |
|
477 | attach(key id) { |
477 | attach(key id) { |
|
478 | llResetScript(); |
478 | llResetScript(); |
|
479 | } |
479 | } |
|
480 | on_rez(integer num) { |
480 | on_rez(integer num) { |
|
481 | llResetScript(); |
481 | llResetScript(); |
|
482 | } |
482 | } |
|
483 | changed(integer change) { |
483 | changed(integer change) { |
|
484 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
484 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
485 | llResetScript(); |
485 | llResetScript(); |
|
486 | } |
486 | } |
|
487 | } |
487 | } |
|
488 | state_exit() { |
488 | state_exit() { |
|
489 | llSetTimerEvent(0); |
489 | llSetTimerEvent(0); |
|
490 | } |
490 | } |
|
491 | } |
491 | } |
|
492 | |
492 | |
|
493 | state touch_primitive { |
493 | state touch_primitive { |
|
494 | state_entry() { |
494 | state_entry() { |
|
495 | // DEBUG |
495 | // DEBUG |
|
496 | llOwnerSay("Touching: " + |
496 | llOwnerSay("Touching: " + |
|
497 | llList2String(names, select) + |
497 | llList2String(names, select) + |
|
498 | " UUID: " + |
498 | " UUID: " + |
|
499 | llList2String(UUIDs, select) |
499 | llList2String(UUIDs, select) |
|
500 | ); |
500 | ); |
|
501 | llInstantMessage( |
501 | llInstantMessage( |
|
502 | (key)wasKeyValueGet( |
502 | (key)wasKeyValueGet( |
|
503 | "corrade", |
503 | "corrade", |
|
504 | configuration |
504 | configuration |
|
505 | ), |
505 | ), |
|
506 | wasKeyValueEncode( |
506 | wasKeyValueEncode( |
|
507 | [ |
507 | [ |
|
508 | "command", "touch", |
508 | "command", "touch", |
|
509 | "group", wasURLEscape( |
509 | "group", wasURLEscape( |
|
510 | wasKeyValueGet( |
510 | wasKeyValueGet( |
|
511 | "group", |
511 | "group", |
|
512 | configuration |
512 | configuration |
|
513 | ) |
513 | ) |
|
514 | ), |
514 | ), |
|
515 | "password", wasURLEscape( |
515 | "password", wasURLEscape( |
|
516 | wasKeyValueGet( |
516 | wasKeyValueGet( |
|
517 | "password", |
517 | "password", |
|
518 | configuration |
518 | configuration |
|
519 | ) |
519 | ) |
|
520 | ), |
520 | ), |
|
521 | "item", wasURLEscape( |
521 | "item", wasURLEscape( |
|
522 | llList2String(UUIDs, select) |
522 | llList2String(UUIDs, select) |
|
523 | ), |
523 | ), |
|
524 | "range", wasURLEscape( |
524 | "range", wasURLEscape( |
|
525 | wasKeyValueGet( |
525 | wasKeyValueGet( |
|
526 | "radar", |
526 | "radar", |
|
527 | configuration |
527 | configuration |
|
528 | ) |
528 | ) |
|
529 | ), |
529 | ), |
|
530 | "callback", wasURLEscape(callback) |
530 | "callback", wasURLEscape(callback) |
|
531 | ] |
531 | ] |
|
532 | ) |
532 | ) |
|
533 | ); |
533 | ); |
|
534 | llSetTimerEvent(60); |
534 | llSetTimerEvent(60); |
|
535 | } |
535 | } |
|
536 | touch_end(integer num) { |
536 | touch_end(integer num) { |
|
537 | llSetColor(<.5,0,0>, ALL_SIDES); |
537 | llSetColor(<.5,0,0>, ALL_SIDES); |
|
538 | llResetScript(); |
538 | llResetScript(); |
|
539 | } |
539 | } |
|
540 | http_request(key id, string method, string body) { |
540 | http_request(key id, string method, string body) { |
|
541 | llHTTPResponse(id, 200, "OK"); |
541 | llHTTPResponse(id, 200, "OK"); |
|
542 | if(wasKeyValueGet("command", body) != "touch" || |
542 | if(wasKeyValueGet("command", body) != "touch" || |
|
543 | wasKeyValueGet("success", body) != "True") { |
543 | wasKeyValueGet("success", body) != "True") { |
|
544 | // DEBUG |
544 | // DEBUG |
|
545 | llOwnerSay("Failed to touch primitive..."); |
545 | llOwnerSay("Failed to touch primitive..."); |
|
546 | llResetScript(); |
546 | llResetScript(); |
|
547 | } |
547 | } |
|
548 | // DEBUG |
548 | // DEBUG |
|
549 | llOwnerSay("Touched..."); |
549 | llOwnerSay("Touched..."); |
|
550 | llResetScript(); |
550 | llResetScript(); |
|
551 | } |
551 | } |
|
552 | timer() { |
552 | timer() { |
|
553 | llResetScript(); |
553 | llResetScript(); |
|
554 | } |
554 | } |
|
555 | attach(key id) { |
555 | attach(key id) { |
|
556 | llResetScript(); |
556 | llResetScript(); |
|
557 | } |
557 | } |
|
558 | on_rez(integer num) { |
558 | on_rez(integer num) { |
|
559 | llResetScript(); |
559 | llResetScript(); |
|
560 | } |
560 | } |
|
561 | changed(integer change) { |
561 | changed(integer change) { |
|
562 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
562 | if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START) || (change & CHANGED_OWNER)) { |
|
563 | llResetScript(); |
563 | llResetScript(); |
|
564 | } |
564 | } |
|
565 | } |
565 | } |
|
566 | state_exit() { |
566 | state_exit() { |
|
567 | llSetTimerEvent(0); |
567 | llSetTimerEvent(0); |
|
568 | } |
568 | } |
|
569 | } |
569 | } |
|
570 | |
570 | |