Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer cooldown = 60;
  2. integer tries = 3;
  3. /////Riddles//////
  4. list clues   = [
  5. "You sit on it, but you can't take it with you...",
  6. "What has a single eye but cannot see?",
  7. "When I'm born, I stay in the sun A little time, and I make crazy When I'm old, I'm worth a fortune, What am I?",
  8. "The more it dries, the wetter it becomes.",
  9. "I cannot hear or even see, but sense light and sounds there may be. Sometimes I end up on the hook, or even deep into a book. What Am I?",
  10. "When you do not know what I am, then I am something. But when you know what I am, then I am nothing. What am I?"];
  11.  
  12. /////Answers//////
  13. list answers = [
  14. "chair",
  15. "needle",
  16. "wine",
  17. "towel",
  18. "worm",
  19. "riddle"];
  20.  
  21. ///////////
  22. integer index;
  23. integer len;
  24. integer reply;
  25. string answer;
  26. integer i;
  27. integer j;
  28. default
  29. {
  30.     state_entry()
  31.     {
  32.         llSetText("Hack Me!",<1,1,1>,1);
  33.         len = llGetListLength(clues);
  34.     }
  35.  
  36.     touch_start(integer total_number)
  37.     {
  38.         index = llFloor(llFrand(len));
  39.         llSay(0, llList2String(clues, index));
  40.         answer = llList2String(answers, index);
  41.         state input;
  42.     }
  43. }
  44.  
  45. state input {
  46.     state_entry(){
  47.         reply = llListen(0,"","","");
  48.         llSetTimerEvent(60);
  49.     }
  50.     listen(integer channel, string name, key id, string msg)
  51.     {
  52.         integer index = llSubStringIndex(msg,answer);
  53.         if(index == -1){
  54.         llSay(0,"Incorrect. "+(string)(tries - i)+" tries left.");
  55.             if (i < (tries-1)){
  56.                 i++;
  57.             }else{
  58.                 state locked;
  59.             }
  60.         }else{
  61.             llSay(0,"Correct!");
  62.             state default;
  63.         }  
  64.     }
  65.     state_exit(){
  66.      llListenRemove(reply);
  67.      i = 0;
  68.     }    
  69. }
  70.  
  71. state locked {
  72.  state_entry(){
  73.         llSetTimerEvent(1.0);
  74.     }  
  75.    
  76.     timer(){
  77.         llSetText("Locked for:" + (string)(cooldown-j) + " Seconds.",<1,0,0>,1);
  78.             if (cooldown > j){
  79.                 j++;
  80.             }else{
  81.                 state default;
  82.             }
  83.     }
  84.     state_exit(){
  85.        j = 0;
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement