SHOW:
|
|
- or go back to the newest paste.
1 | integer visible = TRUE; | |
2 | vector defaultsize; | |
3 | ||
4 | //Random number variable | |
5 | float FloatValue; | |
6 | integer IntValue; | |
7 | string StringValue; | |
8 | ||
9 | integer lchan; | |
10 | ||
11 | integer mchan; //menu channel | |
12 | integer mhandle; | |
13 | key owner; | |
14 | ||
15 | //key id; | |
16 | integer nchan; // to get answer channel | |
17 | integer cchan; //2nd menu channel | |
18 | integer chandle; | |
19 | ||
20 | integer nextmenu; //check for if the 1st menu was answered | |
21 | float FloatValue2; | |
22 | integer IntValue2; | |
23 | string StringValue2; | |
24 | ||
25 | integer fishdrop = FALSE; | |
26 | - | llSetScale(<0.3, 0.3, 0.3>); |
26 | + | list leaderboard; |
27 | integer totalpoints; | |
28 | string username; | |
29 | key unowner; | |
30 | key lid; | |
31 | string lusername; | |
32 | - | llSetScale(<0.6, 0.6, 0.6>); |
32 | + | string ltotalpoints; |
33 | addpoints() | |
34 | { | |
35 | totalpoints += 1; | |
36 | } | |
37 | show() | |
38 | - | llSetScale(<0.9, 0.9, 0.9>); |
38 | + | |
39 | llSetAlpha(1,ALL_SIDES); | |
40 | visible = TRUE; | |
41 | return; | |
42 | } | |
43 | hide() | |
44 | { | |
45 | llSetAlpha(0,ALL_SIDES); | |
46 | - | llListen(-11223,"Fish Pond",NULL_KEY,""); |
46 | + | |
47 | - | llSetAlpha(1,ALL_SIDES); |
47 | + | |
48 | - | defaultsize = llGetScale(); |
48 | + | |
49 | ||
50 | Ssize() | |
51 | { | |
52 | ||
53 | ||
54 | llSetScale(defaultsize/4); | |
55 | ||
56 | - | list tmp = llParseString2List(msg,["_"],[]); // 10. Repeat parsing the essage |
56 | + | |
57 | Msize() | |
58 | - | string cmd = llList2String(tmp,0); |
58 | + | |
59 | ||
60 | - | key rod_owner = (key)llList2String(tmp,1); // 11. We are only working with the rod owner key in this event so do not need to store it ina global variable. |
60 | + | llSetScale(defaultsize/2); |
61 | - | |
61 | + | |
62 | - | if(rod_owner == llGetOwner) //12. We've passed the rod owner jey to the spawner and can now check if they key corresponds to the owner of the sapwner. |
62 | + | |
63 | - | { |
63 | + | |
64 | { | |
65 | - | if(cmd == "on") // 13. Remember to check the parsed message. |
65 | + | |
66 | llSetScale(defaultsize); | |
67 | ||
68 | } | |
69 | Randomcolor() | |
70 | - | else if(cmd == "off") |
70 | + | |
71 | //Red:4,blue:5,green:6,yellow:7,black:8,white:9 | |
72 | ||
73 | - | //llSleep(8.0); |
73 | + | if(StringValue2=="4") // Red |
74 | { | |
75 | llSetLinkColor(LINK_THIS, <1.0, 0.0, 0.0>, ALL_SIDES); | |
76 | - | FloatValue = llFrand(3); |
76 | + | |
77 | else if(StringValue2=="5") // Blue | |
78 | { | |
79 | llSetLinkColor(LINK_THIS, <0.0, 0.0, 1.0>, ALL_SIDES); | |
80 | - | llSay(-11223, "StringValue" +StringValue); |
80 | + | |
81 | else if(StringValue2=="6") // Green | |
82 | - | //llMessageLinked(LINK_SET, 1, "String ", id); |
82 | + | |
83 | llSetLinkColor(LINK_THIS, <0.0, 1.0, 0.0>, ALL_SIDES); | |
84 | } | |
85 | else if(StringValue2=="7") // Yellow | |
86 | - | //llMessageLinked(LINK_SET, 1, "Small Fish", NULL_KEY); |
86 | + | |
87 | llSetLinkColor(LINK_THIS, <1.0, 1.0, 0.0>, ALL_SIDES); | |
88 | } | |
89 | else if(StringValue2=="8") // Black | |
90 | { | |
91 | - | //llMessageLinked(LINK_SET, 2, "Medium Fish",NULL_KEY); |
91 | + | llSetLinkColor(LINK_THIS, <0.0, 0.0, 0.0>, ALL_SIDES); |
92 | } | |
93 | else if(StringValue2=="9") // White | |
94 | { | |
95 | llSetLinkColor(LINK_THIS, <1.0, 1.0, 1.0>, ALL_SIDES); | |
96 | - | //llMessageLinked(LINK_SET, 3, "Big Fish", NULL_KEY); |
96 | + | |
97 | ||
98 | ||
99 | } | |
100 | ||
101 | ||
102 | integer GetCh(key id) // make a unieq channel from the key inputted | |
103 | { | |
104 | return ((integer)("0x"+llGetSubString((string)id,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; | |
105 | - | // touch_start(integer total_number) |
105 | + | |
106 | - | // { |
106 | + | |
107 | - | // if(visible == TRUE) |
107 | + | |
108 | - | // { |
108 | + | key Region() // get the region uuid |
109 | - | // hide(); |
109 | + | |
110 | - | // } |
110 | + | vector z = llGetRegionCorner(); |
111 | - | // else if(visible == FALSE) |
111 | + | |
112 | - | // { |
112 | + | return (key)((string)(z.x/256 + 100*z.y)); |
113 | - | // show(); |
113 | + | |
114 | - | // } |
114 | + | |
115 | - | // } |
115 | + | |
116 | integer allow; // First use a boolean to only allow fishing again once an answer has been given. | |
117 | ||
118 | - | |
118 | + | list ans; // we also need a list to store the buttons. |
119 | ||
120 | list ans2; | |
121 | Timer() | |
122 | { | |
123 | ||
124 | llSetTimerEvent(0.0); | |
125 | llSetTimerEvent(30.0); | |
126 | } | |
127 | ||
128 | default | |
129 | { | |
130 | attach(key id) | |
131 | { | |
132 | ||
133 | if(id) | |
134 | llResetScript(); | |
135 | ||
136 | } | |
137 | ||
138 | state_entry() | |
139 | { | |
140 | ||
141 | hide(); | |
142 | nextmenu = FALSE; | |
143 | allow = TRUE; // allow fishing | |
144 | owner = llGetOwner(); | |
145 | //unowner = llRequestUsername(llGetOwner()); | |
146 | username = llGetUsername(owner); | |
147 | ||
148 | mchan = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -8, -1) ); | |
149 | cchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 567) | 0x8000000; | |
150 | //nchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 123) | 0x8000000; | |
151 | llListen(-11223,"Fish Pond",NULL_KEY,""); | |
152 | ||
153 | defaultsize = <0.4/6, 2.0/6, 5.0/6>; | |
154 | llSetScale(defaultsize); | |
155 | lchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 723) | 0x8000000; | |
156 | llListen(lchan,"Fish Pond",NULL_KEY,""); | |
157 | // llListen(nchan,"Fish Pond",NULL_KEY,""); | |
158 | ||
159 | } | |
160 | ||
161 | listen(integer channel, string what, key who, string msg) | |
162 | { | |
163 | // if(llGetOwnerKey(who) == llGetOwner()) // Note that the message comes from the pond and not the owner of the rod. You can't use llGetOwnerKey(who) because the owner of the pond and the owner of the rod are not necessarily the same owner. | |
164 | ||
165 | ||
166 | ||
167 | if(msg == "on" && allow) // 13. Remember to check the parsed message. | |
168 | { | |
169 | hide(); | |
170 | llSetScale(defaultsize); | |
171 | } | |
172 | else if(msg == "off" && allow) // only catch a fish if allowed | |
173 | { | |
174 | allow = FALSE; | |
175 | llMessageLinked(LINK_SET, 0, "animate", owner); | |
176 | ||
177 | } | |
178 | ||
179 | ||
180 | else if(channel == mchan) | |
181 | { | |
182 | //Check what answer you chose is same to the the fish you caught | |
183 | ||
184 | // We know that the correct answer always comes after the user id in the list. | |
185 | ||
186 | string corans = llList2String(ans,0); // gets the first element and sets it ascorrect answer | |
187 | ||
188 | if(msg=="Small Fish") | |
189 | { | |
190 | if(msg != corans) | |
191 | { | |
192 | llOwnerSay("Wrong Answer"); | |
193 | ||
194 | } | |
195 | else | |
196 | { | |
197 | llOwnerSay("Congratz It right"); | |
198 | addpoints(); | |
199 | ||
200 | } | |
201 | ||
202 | ||
203 | } | |
204 | else if(msg == "Medium Fish") | |
205 | { | |
206 | if(msg != corans) | |
207 | { | |
208 | llOwnerSay("Wrong Answer"); | |
209 | ||
210 | } | |
211 | else | |
212 | { | |
213 | llOwnerSay("Congratz It right"); | |
214 | addpoints(); | |
215 | } | |
216 | } | |
217 | else if(msg == "Big Fish") | |
218 | { | |
219 | if(msg != corans) | |
220 | { | |
221 | llOwnerSay("Wrong Answer"); | |
222 | ||
223 | } | |
224 | else | |
225 | { | |
226 | llOwnerSay("Congratz It right"); | |
227 | addpoints(); | |
228 | } | |
229 | } | |
230 | ||
231 | nextmenu = TRUE; // button was selected so allow fishing again. | |
232 | // llListenRemove(mhandle); | |
233 | ||
234 | ||
235 | if(nextmenu==TRUE) | |
236 | { | |
237 | ||
238 | ||
239 | string answer5; // answer5 will always be the correct answer | |
240 | string answer6; | |
241 | string answer7; | |
242 | string answer8; | |
243 | string answer9; | |
244 | string answer10; | |
245 | if(StringValue2 == "4") //red | |
246 | { | |
247 | ||
248 | answer5= "Red"; | |
249 | answer6= "Blue"; | |
250 | answer7= "Green"; | |
251 | answer8= "Yellow"; | |
252 | answer9= "Black"; | |
253 | answer10= "White"; | |
254 | } | |
255 | else if(StringValue2 == "5") //blue | |
256 | { | |
257 | answer5= "Blue"; | |
258 | answer6= "Red"; | |
259 | answer7= "Green"; | |
260 | answer8= "Yellow"; | |
261 | answer9= "Black"; | |
262 | answer10= "White"; | |
263 | ||
264 | } | |
265 | else if(StringValue2 == "6") //green | |
266 | { | |
267 | answer5= "Green"; | |
268 | answer6= "Blue"; | |
269 | answer7= "Red"; | |
270 | answer8= "Yellow"; | |
271 | answer9= "Black"; | |
272 | answer10= "White"; | |
273 | } | |
274 | else if(StringValue2 == "7") //yellow | |
275 | { | |
276 | answer5= "Yellow"; | |
277 | answer6= "Blue"; | |
278 | answer7= "Green"; | |
279 | answer8= "Red"; | |
280 | answer9= "Black"; | |
281 | answer10= "White"; | |
282 | ||
283 | } | |
284 | else if(StringValue2 == "8") //black | |
285 | { | |
286 | answer5= "Black"; | |
287 | answer6= "Blue"; | |
288 | answer7= "Green"; | |
289 | answer8= "Yellow"; | |
290 | answer9= "Red"; | |
291 | answer10= "White"; | |
292 | } | |
293 | else if(StringValue2 == "9") //white | |
294 | { | |
295 | answer5= "White"; | |
296 | answer6= "Blue"; | |
297 | answer7= "Green"; | |
298 | answer8= "Yellow"; | |
299 | answer9= "Black"; | |
300 | answer10= "Red"; | |
301 | } | |
302 | string cquestion = "\n" + "What color Fish did you caught?"; | |
303 | ans2 = [answer5] + [answer6] + [answer7] + [answer8] + [answer9] + [answer10]; | |
304 | list crand_buttons = llListRandomize( llList2List(ans2,0,-1),1); | |
305 | list cbuttons = crand_buttons; // set the buttons as the new list. | |
306 | ||
307 | llListenRemove(chandle); | |
308 | chandle = llListen(cchan, "", owner, ""); | |
309 | // llOwnerSay((string)ans2); | |
310 | llDialog(owner, cquestion, cbuttons, cchan); | |
311 | Timer(); | |
312 | //allow = FALSE; // don't allow fishing again until a button is selected | |
313 | string corans2 = llList2String(ans2,0); | |
314 | // llOwnerSay("The ans for color is: " + corans2); | |
315 | } | |
316 | ||
317 | } | |
318 | else if(channel == cchan) | |
319 | { | |
320 | //find the answer | |
321 | ||
322 | ||
323 | ||
324 | string corans2 = llList2String(ans2,0); | |
325 | // llOwnerSay("Fish Colour is: " + corans2); | |
326 | if(msg == "Red") | |
327 | { | |
328 | if(msg != corans2) | |
329 | { | |
330 | llOwnerSay("Too bad, that's wrong"); | |
331 | } | |
332 | else | |
333 | { | |
334 | llOwnerSay("Congratz, you're right"); | |
335 | addpoints(); | |
336 | } | |
337 | ||
338 | } | |
339 | else if(msg == "Blue") | |
340 | { | |
341 | if(msg != corans2) | |
342 | { | |
343 | llOwnerSay("Too bad, that's wrong"); | |
344 | ||
345 | } | |
346 | else | |
347 | { | |
348 | llOwnerSay("Congratz, you're right"); | |
349 | addpoints(); | |
350 | } | |
351 | ||
352 | } | |
353 | else if(msg == "Green") | |
354 | { | |
355 | if(msg != corans2) | |
356 | { | |
357 | llOwnerSay("Too bad, that's wrong"); | |
358 | ||
359 | } | |
360 | else | |
361 | { | |
362 | llOwnerSay("Congratz, you're right"); | |
363 | addpoints(); | |
364 | } | |
365 | ||
366 | } | |
367 | else if(msg == "Yellow") | |
368 | { | |
369 | if(msg != corans2) | |
370 | { | |
371 | llOwnerSay("Too bad, that's wrong"); | |
372 | ||
373 | } | |
374 | else | |
375 | { | |
376 | llOwnerSay("Congratz, you're right"); | |
377 | addpoints(); | |
378 | } | |
379 | ||
380 | } | |
381 | else if(msg == "Black") | |
382 | { | |
383 | if(msg != corans2) | |
384 | { | |
385 | llOwnerSay("Too bad, that's wrong"); | |
386 | ||
387 | ||
388 | } | |
389 | else | |
390 | { | |
391 | llOwnerSay("Congratz, you're right"); | |
392 | addpoints(); | |
393 | } | |
394 | ||
395 | } | |
396 | else if(msg == "White") | |
397 | { | |
398 | if(msg != corans2) | |
399 | { | |
400 | llOwnerSay("Too bad, that's wrong"); | |
401 | } | |
402 | else | |
403 | { | |
404 | llOwnerSay("Congratz, you're right"); | |
405 | addpoints(); | |
406 | } | |
407 | ||
408 | } | |
409 | list leaderboard = [owner]+"|" + [username]+"|" + [totalpoints]; // 3 Elements in a List | |
410 | ||
411 | // llOwnerSay("leaderboard: "+ (string)leaderboard); | |
412 | llSay( GetCh(Region()) - 35, (string)leaderboard); | |
413 | ||
414 | ||
415 | nextmenu = FALSE; | |
416 | allow = TRUE; | |
417 | ||
418 | } | |
419 | ||
420 | } | |
421 | ||
422 | link_message(integer sender,integer num, string msg, key id) | |
423 | { | |
424 | ||
425 | ||
426 | if(msg == "stopanimate"&& id == owner ) | |
427 | { | |
428 | ||
429 | ||
430 | ||
431 | ||
432 | ||
433 | //llSleep(8.0); | |
434 | show(); | |
435 | //random number generator | |
436 | ||
437 | FloatValue = 3.0 - llFrand(2.0); | |
438 | IntValue = llRound(FloatValue); | |
439 | StringValue = (string)IntValue; | |
440 | FloatValue2 = 9.0 - llFrand(5.0); | |
441 | IntValue2 = llRound(FloatValue2); | |
442 | StringValue2 = (string)IntValue2; | |
443 | // llOwnerSay("Int is " + StringValue); | |
444 | ||
445 | llSay(GetCh(Region()) - 34, StringValue); //offset must be the same as in the instruction board | |
446 | // we don't need to send the value to the instruction board. | |
447 | ||
448 | // llSay(0,"fish region chan: " + (string)(GetCh(Region()) - 34)); | |
449 | ||
450 | ||
451 | if(IntValue == 1) | |
452 | { | |
453 | Ssize(); | |
454 | Randomcolor(); | |
455 | } | |
456 | else if(IntValue == 2) | |
457 | { | |
458 | Msize(); | |
459 | Randomcolor(); | |
460 | } | |
461 | else if(IntValue == 3) | |
462 | { | |
463 | Bsize(); | |
464 | Randomcolor(); | |
465 | } | |
466 | ||
467 | llSay(cchan, (string) StringValue2); | |
468 | string answer2; | |
469 | string answer3; | |
470 | string answer4; // variable to store the buttons | |
471 | ||
472 | if(StringValue == "1") | |
473 | { | |
474 | ||
475 | answer2= "Small Fish"; | |
476 | answer3= "Medium Fish"; | |
477 | answer4= "Big Fish"; | |
478 | } | |
479 | else if(StringValue == "2") | |
480 | { | |
481 | answer2= "Medium Fish"; | |
482 | answer3= "Small Fish"; | |
483 | answer4= "Big Fish"; | |
484 | } | |
485 | else if(StringValue == "3") | |
486 | { | |
487 | answer2= "Big Fish"; | |
488 | answer3= "Medium Fish"; | |
489 | answer4= "Small Fish"; | |
490 | ||
491 | } // we got the buttons | |
492 | ||
493 | // Now lets get the dialog set up. | |
494 | string question = "\n" + "What Fish have you caught?"; | |
495 | ans = [answer2] + [answer3] +[answer4]; | |
496 | list rand_buttons = llListRandomize( llList2List(ans,0,-1),1); //make a new list and randomize the buttons. This will retain the order of the original list. | |
497 | ||
498 | list buttons = rand_buttons; // set the buttons as the new list. | |
499 | ||
500 | llListenRemove(mhandle); | |
501 | mhandle = llListen(mchan, "", owner, ""); | |
502 | // llOwnerSay((string)ans); | |
503 | llDialog(owner, question, buttons, mchan); | |
504 | Timer(); | |
505 | allow = FALSE; // don't allow fishing again until a button is selected | |
506 | string corans = llList2String(ans,0); | |
507 | // llOwnerSay("The ans for size is: " + corans); | |
508 | ||
509 | ||
510 | } | |
511 | ||
512 | ||
513 | ||
514 | ||
515 | ||
516 | } | |
517 | ||
518 | timer() // After 60 seconds this event will run | |
519 | { | |
520 | ||
521 | llSetTimerEvent(0.0); | |
522 | llListenRemove(mhandle); // Removes mhandle instance | |
523 | llListenRemove(chandle); | |
524 | llOwnerSay("Menu timed out.Please try again"); | |
525 | allow = TRUE; // if user doesn't click a button drop the fish and allow fishing again. | |
526 | ||
527 | } | |
528 | ||
529 | ||
530 | } |