Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string question;
- string correctanswer;
- string sparecorrectanswer;
- string checkanswer;
- string answer2;
- string answer3;
- string answer4;
- list buttons;
- key touchid;
- integer mchan; //menu channel
- integer mhandle;
- integer gchan; //fish spawn channel
- integer ghandle;
- integer fchan;
- integer IntValue;
- default
- {
- state_entry()
- {
- mchan = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -8, -1) );
- question = "\n" + "What Fish did you caught?";
- llListenRemove(ghandle);
- gchan = -11223;
- ghandle = llListen(-11223, "", "", "");
- answer2 = "a";
- answer3 = "b";
- answer4 = "c";
- fchan = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) - 800) | 0x8000000;
- llListen(fchan,"Fish",NULL_KEY,"");
- }
- touch_start(integer num_detected)
- {
- touchid = llDetectedKey(0);
- llListenRemove(mhandle);
- mhandle = llListen(mchan, "", touchid, "");
- llDialog(touchid, question, buttons, mchan);
- llSetTimerEvent(0.0);
- llSetTimerEvent(60.0);
- }
- listen(integer channel, string name, key id, string msg)
- {
- //Listen for correct answer
- if(channel == fchan)
- {
- llSay(0,"Answer Recieve");
- //determine the correct answer and set up the multiple question
- IntValue = (integer)msg;
- sparecorrectanswer = (string)IntValue;
- correctanswer = (string)IntValue;
- answer2 = correctanswer;
- if(answer2 == "1")
- {
- checkanswer = "1";
- answer2= "Small Fish";
- answer3= "Medium Fish";
- answer4= "Big Fish";
- }
- else if(answer2 == "2")
- {
- checkanswer = "2";
- answer2= "Medium Fish";
- answer3= "Small Fish";
- answer4= "Big Fish";
- }
- else if(answer2 == "3")
- {
- checkanswer = "3";
- answer2= "Big Fish";
- answer3= "Medium Fish";
- answer4= "Small Fish";
- }
- else
- {
- //Remove Menu
- answer2= "NIL";
- answer3= "NIL";
- answer4= "NIL";
- }
- buttons = [answer2,answer3,answer4];
- }
- if(channel == mchan)
- {
- //Check what answer you chose is same to the the fish you catched
- if(msg=="Small Fish")
- {
- if(msg != answer2)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- }
- }
- else if(msg == "Medium Fish")
- {
- if(msg != answer2)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- }
- }
- else if(msg == "Big Fish")
- {
- if(msg != answer2)
- {
- llSay(0,"Wrong Answer");
- }
- else
- {
- llSay(0,"Congratz It right");
- }
- }
- llListenRemove(mhandle);
- }
- }
- timer() // After 60 seconds this event will run
- {
- llSetTimerEvent(0.0);
- llListenRemove(mhandle); // Removes mhandle instance
- llSay(0,"Menu times out.Please try again");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement