Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer visible = TRUE;
- vector defaultsize;
- //Random number variable
- float FloatValue;
- integer IntValue;
- string StringValue;
- integer lchan;
- integer mchan; //menu channel
- integer mhandle;
- key owner;
- //key id;
- integer nchan; // to get answer channel
- integer cchan; //2nd menu channel
- integer chandle;
- integer nextmenu; //check for if the 1st menu was answered
- float FloatValue2;
- integer IntValue2;
- string StringValue2;
- integer fishdrop = FALSE;
- list leaderboard;
- integer totalpoints;
- string username;
- key unowner;
- key lid;
- string lusername;
- string ltotalpoints;
- string cmd2;
- float fishingtime;
- float fishingcounter;
- integer ifishingtime;
- integer animation = FALSE;
- integer stopmtimer = TRUE;
- fishtime()
- {
- fishingtime = 10.0 - llFrand(3.0);
- ifishingtime = (integer)fishingtime;
- llSay(0,"Fishing time: "+ (string)fishingtime);
- for(fishingcounter = 0; fishingcounter<= ifishingtime; ++fishingcounter)
- {
- llSetTimerEvent(fishingtime);
- animation = TRUE;
- }
- llSleep(0.3);
- }
- addpoints()
- {
- totalpoints += 1;
- }
- show()
- {
- llSetAlpha(1,ALL_SIDES);
- visible = TRUE;
- return;
- }
- hide()
- {
- llSetAlpha(0,ALL_SIDES);
- visible = FALSE;
- return;
- }
- Ssize()
- {
- llSetScale(defaultsize/4);
- }
- Msize()
- {
- llSetScale(defaultsize/2);
- }
- Bsize()
- {
- llSetScale(defaultsize);
- }
- Randomcolor()
- {
- //Red:4,blue:5,green:6,yellow:7,black:8,white:9
- if(StringValue2=="4") // Red
- {
- llSetLinkColor(LINK_THIS, <1.0, 0.0, 0.0>, ALL_SIDES);
- }
- else if(StringValue2=="5") // Blue
- {
- llSetLinkColor(LINK_THIS, <0.0, 0.0, 1.0>, ALL_SIDES);
- }
- else if(StringValue2=="6") // Green
- {
- llSetLinkColor(LINK_THIS, <0.0, 1.0, 0.0>, ALL_SIDES);
- }
- else if(StringValue2=="7") // Yellow
- {
- llSetLinkColor(LINK_THIS, <1.0, 1.0, 0.0>, ALL_SIDES);
- }
- else if(StringValue2=="8") // Black
- {
- llSetLinkColor(LINK_THIS, <0.0, 0.0, 0.0>, ALL_SIDES);
- }
- else if(StringValue2=="9") // White
- {
- llSetLinkColor(LINK_THIS, <1.0, 1.0, 1.0>, ALL_SIDES);
- }
- }
- integer GetCh(key id) // make a unieq channel from the key inputted
- {
- return ((integer)("0x"+llGetSubString((string)id,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
- }
- key Region() // get the region uuid
- {
- vector z = llGetRegionCorner();
- return (key)((string)(z.x/256 + 100*z.y));
- }
- integer allow; // First use a boolean to only allow fishing again once an answer has been given.
- list ans; // we also need a list to store the buttons.
- list ans2;
- Timer()
- {
- llSetTimerEvent(0.0);
- llSetTimerEvent(60.0);
- }
- default
- {
- attach(key id)
- {
- if(id)
- llResetScript();
- }
- state_entry()
- {
- nextmenu = FALSE;
- allow = TRUE; // allow fishing
- owner = llGetOwner();
- //unowner = llRequestUsername(llGetOwner());
- username = llGetUsername(owner);
- mchan = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -8, -1) );
- cchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 567) | 0x8000000;
- //nchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 123) | 0x8000000;
- llListen(-11223,"Fish Pond",NULL_KEY,"");
- llSetAlpha(1,ALL_SIDES);
- defaultsize = <0.4/6, 2.0/6, 5.0/6>;
- llSetScale(defaultsize);
- lchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 723) | 0x8000000;
- llListen(lchan,"Fish Pond",NULL_KEY,"");
- // llListen(nchan,"Fish Pond",NULL_KEY,"");
- llListen(-66778,"Fishing Rod",NULL_KEY,"");
- }
- listen(integer channel, string what, key who, string msg)
- {
- // 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.
- if(msg == "on" && allow ) // 13. Remember to check the parsed message.
- {
- hide();
- llSetScale(defaultsize);
- }
- else if(msg == "off" && allow ) // only catch a fish if allowed
- {
- //allow = FALSE;
- //fishtime();
- //llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
- //llSetTimerEvent(0.0);
- //llSay(0,"fishing time: "+(string)ifishingtime);
- state wait_animation;
- show();
- //random number generator
- FloatValue = 3.0 - llFrand(2.0);
- IntValue = llRound(FloatValue);
- StringValue = (string)IntValue;
- FloatValue2 = 9.0 - llFrand(5.0);
- IntValue2 = llRound(FloatValue2);
- StringValue2 = (string)IntValue2;
- // llOwnerSay("Int is " + StringValue);
- // llSay(GetCh(Region()) - 34, StringValue); //offset must be the same as in the instruction board
- // we don't need to send the value to the instruction board.
- llSay(0,"fish region chan: " + (string)(GetCh(Region()) - 34));
- if(IntValue == 1)
- {
- Ssize();
- Randomcolor();
- }
- else if(IntValue == 2)
- {
- Msize();
- Randomcolor();
- }
- else if(IntValue == 3)
- {
- Bsize();
- Randomcolor();
- }
- llSay(cchan, (string) StringValue2);
- string answer2;
- string answer3;
- string answer4; // variable to store the buttons
- if(StringValue == "1")
- {
- answer2= "Small Fish";
- answer3= "Medium Fish";
- answer4= "Big Fish";
- }
- else if(StringValue == "2")
- {
- answer2= "Medium Fish";
- answer3= "Small Fish";
- answer4= "Big Fish";
- }
- else if(StringValue == "3")
- {
- answer2= "Big Fish";
- answer3= "Medium Fish";
- answer4= "Small Fish";
- } // we got the buttons
- // Now lets get the dialog set up.
- string question = "\n" + "What Fish have you caught?";
- ans = [answer2] + [answer3] +[answer4];
- 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.
- list buttons = rand_buttons; // set the buttons as the new list.
- llListenRemove(mhandle);
- mhandle = llListen(mchan, "", owner, "");
- llOwnerSay((string)ans);
- llDialog(owner, question, buttons, mchan);
- Timer();
- allow = FALSE; // don't allow fishing again until a button is selected
- string corans = llList2String(ans,0);
- llOwnerSay("The ans for size is: " + corans);
- }
- else if(channel == mchan)
- {
- //Check what answer you chose is same to the the fish you caught
- // We know that the correct answer always comes after the user id in the list.
- string corans = llList2String(ans,0); // gets the first element and sets it ascorrect answer
- if(msg=="Small Fish")
- {
- if(msg != corans)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- addpoints();
- }
- }
- else if(msg == "Medium Fish")
- {
- if(msg != corans)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- addpoints();
- }
- }
- else if(msg == "Big Fish")
- {
- if(msg != corans)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- addpoints();
- }
- }
- nextmenu = TRUE; // button was selected so allow fishing again.
- // llListenRemove(mhandle);
- if(nextmenu==TRUE)
- {
- string answer5; // answer5 will always be the correct answer
- string answer6;
- string answer7;
- string answer8;
- string answer9;
- string answer10;
- if(StringValue2 == "4") //red
- {
- answer5= "Red";
- answer6= "Blue";
- answer7= "Green";
- answer8= "Yellow";
- answer9= "Black";
- answer10= "White";
- }
- else if(StringValue2 == "5") //blue
- {
- answer5= "Blue";
- answer6= "Red";
- answer7= "Green";
- answer8= "Yellow";
- answer9= "Black";
- answer10= "White";
- }
- else if(StringValue2 == "6") //green
- {
- answer5= "Green";
- answer6= "Blue";
- answer7= "Red";
- answer8= "Yellow";
- answer9= "Black";
- answer10= "White";
- }
- else if(StringValue2 == "7") //yellow
- {
- answer5= "Yellow";
- answer6= "Blue";
- answer7= "Green";
- answer8= "Red";
- answer9= "Black";
- answer10= "White";
- }
- else if(StringValue2 == "8") //black
- {
- answer5= "Black";
- answer6= "Blue";
- answer7= "Green";
- answer8= "Yellow";
- answer9= "Red";
- answer10= "White";
- }
- else if(StringValue2 == "9") //white
- {
- answer5= "White";
- answer6= "Blue";
- answer7= "Green";
- answer8= "Yellow";
- answer9= "Black";
- answer10= "Red";
- }
- string cquestion = "\n" + "What color Fish did you caught?";
- ans2 = [answer5] + [answer6] + [answer7] + [answer8] + [answer9] + [answer10];
- list crand_buttons = llListRandomize( llList2List(ans2,0,-1),1);
- list cbuttons = crand_buttons; // set the buttons as the new list.
- llListenRemove(chandle);
- chandle = llListen(cchan, "", owner, "");
- llOwnerSay((string)ans2);
- llDialog(owner, cquestion, cbuttons, cchan);
- //if(stopmtimer == FALSE)
- //{
- Timer();
- //}
- //allow = FALSE; // don't allow fishing again until a button is selected
- string corans2 = llList2String(ans2,0);
- llOwnerSay("The ans for color is: " + corans2);
- }
- }
- else if(channel == cchan)
- {
- //find the answer
- string corans2 = llList2String(ans2,0);
- llOwnerSay("Fish Colour is: " + corans2);
- if(msg == "Red")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0, "Congratz, you're right");
- addpoints();
- }
- }
- else if(msg == "Blue")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0, "Congratz, you're right");
- addpoints();
- }
- }
- else if(msg == "Green")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0, "Congratz, you're right");
- addpoints();
- }
- }
- else if(msg == "Yellow")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0, "Congratz, you're right");
- addpoints();
- }
- }
- else if(msg == "Black")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0,"Congratz, you're right");
- addpoints();
- }
- }
- else if(msg == "White")
- {
- if(msg != corans2)
- {
- llSay(0, "Too bad, that's wrong");
- }
- else
- {
- llSay(0, "Congratz, you're right");
- addpoints();
- }
- }
- list leaderboard = [owner]+"|" + [username]+"|" + [totalpoints]; // 3 Elements in a List
- llOwnerSay("leaderboard: "+ (string)leaderboard);
- llSay( GetCh(Region()) - 35, (string)leaderboard);
- nextmenu = FALSE;
- allow = TRUE;
- }
- }
- /*
- run_time_permissions(integer permissions)
- {
- if (permissions & PERMISSION_TRIGGER_ANIMATION)
- { // If permission to animate was granted, start the animation.
- llStartAnimation("Fishing Middle Animation");
- llSay(0,"Animation started");
- llSleep(fishingtime);
- animation = FALSE;
- if(animation == FALSE);
- {
- llSay(0,"Animation stop");
- llStopAnimation("Fishing Middle Animation");
- }
- }
- }
- */
- timer() // After 60 seconds this event will run
- {
- llSetTimerEvent(0.0);
- llListenRemove(mhandle); // Removes mhandle instance
- llListenRemove(chandle);
- llSay(0,"Menu timed out.Please try again");
- allow = TRUE; // if user doesn't click a button drop the fish and allow fishing again.
- }
- state_exit()
- {
- llSay(0, "The script leaves the default state.");
- }
- }
- state wait_animation
- {
- state_entry()
- {
- key owner;
- owner = llGetOwner();
- llSay(0, "The script entered state 'two'");
- llMessageLinked(LINK_THIS, 0, "Fishing Time/Anim", owner);
- }
- link_message(integer source, integer num, string str, key id)
- {
- key ownerid;
- ownerid = llGetOwner();
- if(ownerid== id )
- {
- state default;
- }
- }
- state_exit()
- {
- llSay(0, "The script leaves state 'wait_animation'");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement