zzzz

Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Suggestion Box Suggestion_Box  

Suggestion_Box

To use this script, simply copy/paste the contents below into a New Script in the game. Then place the script into a ‘prim’ (in the shape of a mailbox or suggestion box?). That’s all there is to it.

Category: Suggestion Box
By : dakar Muliaina
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life + OpenSim

the Zip file

Download all files for Suggestion_Box
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Suggestion_Box_1.lsl
1 // --------------------------------------//
2
3 // This script transform a prim to a Mail Box.
4
5 // Folks can drop notecard to the box.
6
7 // Read/unread information is displayed as hovering text.
8
9 // You can copy/modify this script, it's totally free.
10
11 // --------------------------------------//
12
13 // Modified by dakar Muliaina, converted to The king's English
14
15 // and a few other enhancements.
16
17 //-------------------------------------------//
18
19
20
21 list lMail = [];
22
23 // column 1 = notecard name, column 2 = read by user
24
25 integer MAIL_UNREADED = 0;
26
27 integer MAIL_READED = 1;
28
29 integer DIALOG_CHANNEL = 49383;
30
31 list DIALOG_CHOICE =
32
33 ["Unread",
34
35 "Read",
36
37 "Delete"];
38
39 integer nLastCardCount = 0;
40
41 integer nLastItemCount = 0;
42
43
44
45 TxtRefresh()
46
47 {
48
49 // show the unreadable notecard
50
51 integer nTotalCard = 0;
52
53 integer nNotReaded = 0;
54
55 integer nCount = 0;
56
57 for (nCount = 0; nCount < llGetListLength(lMail); nCount += 2)
58
59 {
60
61 if (llList2Integer(lMail, nCount + 1) == MAIL_UNREADED)
62
63 nNotReaded += 1;
64
65 nTotalCard += 1;
66
67 }
68
69
70
71 // total string
72
73 string cPost = (string)nTotalCard + " card";
74
75 if (nTotalCard > 1) cPost += "s";
76
77 cPost += " posted";
78
79
80
81 // unreaded string
82
83 string cUnreaded = (string)nNotReaded + " unread";
84
85 llSetText("Suggestion Box!\n" + cPost + "\n" + cUnreaded, <.95, .75, 0>, 1);
86
87 }
88
89
90
91 default
92
93 {
94
96
97 {
98
99 // Allowing dropping of object
100
102
103 llListen(DIALOG_CHANNEL, "", NULL_KEY, "");
104
105 nLastCardCount = llGetInventoryNumber(INVENTORY_ALL);
106
108
109
110
111 // Auto complete list
112
114
115 integer n_CurObj = 0;
116
117 string c_Name = "NotEmpty";
118
119 while (c_Name != "")
120
121 {
122
123 c_Name = llGetInventoryName(INVENTORY_NOTECARD, n_CurObj);
124
125 n_CurObj += 1;
126
127 if (c_Name != "")
128
129 {
130
131 lMail += [c_Name];
132
133 lMail += MAIL_UNREADED;
134
135 }
136
137 }
138
139 TxtRefresh();
140
141 }
142
143
144
145 touch_start(integer total_number)
146
147 {
148
149 llSay(0, "Drop a notecard to be sent to MY OWNER.");
150
151 //---- Change MY OWNER above to suit your likes and needs. //
152
153 // if owner
154
155 key id = llDetectedKey(0);
156
157 if (id == llGetOwner())
158
159 {
160
161 // Show a dialog
162
163 llDialog(id, "What do you want to do ?", DIALOG_CHOICE,
164
165 DIALOG_CHANNEL);
166
167 }
168
169 }
170
171
172
173 listen(integer channel, string name, key id, string message)
174
175 {
176
177 if (llGetOwner() == id && llListFindList(DIALOG_CHOICE,
178
179 [message]) != -1)
180
181 {
182
184
185 string cName;
186
187 list lRemove;
188
189 integer nStatus;
190
191 for (i = 0; i < llGetListLength(lMail); i += 2)
192
193 {
194
195 cName = llList2String(lMail, i);
196
197 nStatus = llList2Integer(lMail, i + 1);
198
199 if (message == llList2String(DIALOG_CHOICE, 0)
200
201 && nStatus == MAIL_UNREADED)
202
203 {
204
205 // open un-readed
206
207 llGiveInventory(id, cName);
208
209 // mark for readed
210
211 lMail = llListReplaceList(lMail, [MAIL_READED],
212
213 i + 1, i + 1);
214
215 }
216
217 if (message == llList2String(DIALOG_CHOICE, 1)
218
219 && nStatus == MAIL_READED)
220
221 {
222
223 // open readed
224
225 llGiveInventory(id, cName);
226
227 }
228
229 if (message == llList2String(DIALOG_CHOICE, 2)
230
231 && nStatus == MAIL_READED)
232
233 {
234
235 // delete readed
236
237 llSay(0, cName);
238
239 llRemoveInventory(cName);
240
241 lRemove += i;
242
243 }
244
245 }
246
247 // remove from the list
248
249 if (llGetListLength(lRemove) > 0)
250
251 {
252
254
255 for (k = 0; k < llGetListLength(lRemove); k++)
256
257 {
258
259 i = llList2Integer(lRemove, k);
260
261 lMail = llDeleteSubList(lMail, i, i+1);
262
263 }
264
265 }
266
267 TxtRefresh();
268
269 }
270
271 }
272
273
274
275 changed(integer change)
276
277 {
278
279 // dont accept other than a notecard
280
282
283 if (nItemCount < 2)
284
285 {
286
287 // clear the list
288
289 lMail = [];
290
291 }
292
293
294
295 if (nItemCount != nLastItemCount)
296
297 {
298
299 // delete other item type than notecard
300
301 string cName = "NotEmpty";
302
303 integer nCurObj = 0;
304
306
307 list lRemove = [];
308
309 while (cName != "")
310
311 {
312
313 cName = llGetInventoryName(INVENTORY_ALL, nCurObj);
314
315 nCurObj += 1;
316
317 nObjType = llGetInventoryType(cName);
318
319 if (nObjType != INVENTORY_NOTECARD)
320
321 {
322
323 // add for deletion, its not a notecard
324
325 lRemove += cName;
326
327 }
328
329 }
330
331
332
333 // delete other object than notecard
334
335 integer nD = 0;
336
337 for (nD = 0; nD < llGetListLength(lRemove); nD += 1)
338
339 {
340
341 // dont remove this script !
342
343 cName = llList2String(lRemove, nD);
344
345 if (cName != llGetScriptName() && cName != "")
346
347 {
348
349 llSay(0, "Sorry but " + cName + " is not a notecard.");
350
351 llRemoveInventory(cName);
352
353 }
354
355 }
356
357
358
359 // search for a new notecard
360
361 integer n_CurObj = 0;
362
363 string c_Name = "NotEmpty";
364
365 while (c_Name != "")
366
367 {
368
369 c_Name = llGetInventoryName(INVENTORY_NOTECARD, n_CurObj);
370
371 llSay(0, c_Name);
372
373 n_CurObj += 1;
374
375 // search for this card
376
377 if (llListFindList(lMail, [c_Name]) == -1 && c_Name != "")
378
379 {
380
381 // ok its a new card
382
383 lMail += [c_Name];
384
385 lMail += MAIL_UNREADED;
386
387 llSay(0, c_Name + " added to the mailbox.");
388
389 }
390
391 }
392
393 }
394
395 nLastItemCount = llGetInventoryNumber(INVENTORY_ALL);
396
398
399 // refresh the text
400
401 TxtRefresh();
402
403 }
404
405 }