Advertisement
gabzox

Untitled

Apr 13th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///free to use and give away
  2. ///created by assistantofgabzo Resident
  3. //write each hint on a seperate line
  4. integer CHANNEL;
  5.  
  6. string notecardName;
  7. list clues;
  8. list clueButtons;
  9. integer totalClues;
  10. integer notecardLine;
  11. key notecardQueryId;
  12. key currentUser;
  13. integer listenHandle;
  14.  
  15. list order_buttons(list buttons)
  16. {
  17.     return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) +
  18.         llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
  19. }
  20.  
  21. integer menuindex;
  22.  
  23. DialogPlus(key avatar, string message, list buttons, integer channel, integer CurMenu)
  24. {
  25.     if (12 < llGetListLength(buttons))
  26.     {
  27.         list lbut = buttons;
  28.         list Nbuttons = [];
  29.         if(CurMenu == -1)
  30.         {
  31.             CurMenu = 0;
  32.             menuindex = 0;
  33.         }
  34.  
  35.         if((Nbuttons = (llList2List(buttons, (CurMenu * 10), ((CurMenu * 10) + 9)) + ["Back", "Next"])) == ["Back", "Next"])
  36.             DialogPlus(avatar, message, lbut, channel, menuindex = 0);
  37.         else
  38.             llDialog(avatar, message,  order_buttons(Nbuttons), channel);
  39.     }
  40.     else
  41.         llDialog(avatar, message,  order_buttons(buttons), channel);
  42. }
  43.  
  44. default
  45. {
  46.     state_entry()
  47.     {
  48.         CHANNEL = (integer)llFrand(-999999.);
  49.         if (llGetInventoryNumber( INVENTORY_NOTECARD ) == 1)
  50.         {
  51.             notecardName = llGetInventoryName(INVENTORY_NOTECARD,0);
  52.            
  53.             if (llGetInventoryKey(notecardName) == NULL_KEY)
  54.             {
  55.             llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten");
  56.             return;
  57.             }
  58.             notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
  59.         }
  60.         else
  61.         {
  62.             llOwnerSay("please add a single notecard with all your clues. put each clue on a seperate line");
  63.  
  64.         }
  65.     }
  66.  
  67.     touch_start(integer total_number)
  68.     {
  69.     }
  70.     dataserver(key query_id, string data)
  71.     {
  72.         if (query_id == notecardQueryId)
  73.         {
  74.             if (data == EOF)
  75.             {
  76.                 llOwnerSay ("you have " + (string)(notecardLine) + " clues");
  77.                 state ready;
  78.             }
  79.             else
  80.             {
  81.                 clueButtons+=(string)notecardLine;
  82.                 // bump line number for reporting purposes and in preparation for reading next line
  83.                 ++notecardLine;
  84.                 clues += data + ".";
  85.                 notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
  86.             }
  87.         }
  88.     }
  89.     changed(integer change)
  90.     {
  91.         if (change & CHANGED_INVENTORY)
  92.         {
  93.             llResetScript();
  94.         }
  95.     }
  96. }
  97.  
  98. state ready
  99. {
  100.     state_entry()
  101.     {
  102.         currentUser = NULL_KEY;
  103.     }
  104.     changed(integer change)
  105.     {
  106.         if (change & CHANGED_INVENTORY)
  107.         {
  108.             llResetScript();
  109.         }
  110.     }
  111.     touch_start(integer n)
  112.     {
  113.         if(currentUser == NULL_KEY || llDetectedKey(0) == currentUser )
  114.         {
  115.             currentUser = llDetectedKey(0);
  116.             llSetText ("in use by: " + llKey2Name(currentUser),<1,1,1>,1.0);
  117.             listenHandle = llListen(CHANNEL, "", currentUser, "");
  118.             llSetTimerEvent(30.);
  119.             DialogPlus(currentUser, "Select an Option", clueButtons, CHANNEL, menuindex = 0);
  120.         }
  121.     }
  122.     listen(integer chan, string name, key id, string msg)
  123.     {
  124.         key owner = llGetOwner();
  125.  
  126.         // If they clicked Next it will go to the next dialog window
  127.         if(msg == "Next")
  128.         {
  129.             // ++menuindex will turn menuindex plus 1, making it give the next page.
  130.             DialogPlus(currentUser, "Select an Option", clueButtons, CHANNEL, ++menuindex);
  131.             llSetTimerEvent(30.);
  132.         }
  133.  
  134.         // if they clicked back it will go to the last dialog window.
  135.         else if(msg == "Back")
  136.         {
  137.             DialogPlus(currentUser, "Select an Option", clueButtons, CHANNEL, --menuindex);
  138.             llSetTimerEvent(30.);
  139.         }
  140.             // --menuindex will turn menuindex minus 1, making it give the previous page.
  141.  
  142.         // If they choose anything besides Back/Next it will be in this section
  143.         else
  144.         {
  145.             // Be Safe
  146.             llListenRemove(listenHandle);
  147.             //Example used, change to whatever you wish.
  148.              if ( (string) ( (integer) msg) == msg)
  149.              {
  150.                  llDialog(currentUser,(llList2String(clues,(integer) msg)),["ok"],CHANNEL);
  151.                  llSetTimerEvent(0.1);
  152.              }
  153.         }
  154.     }
  155.     timer()
  156.     {
  157.         llSetTimerEvent(0);
  158.         currentUser == NULL_KEY;
  159.         llListenRemove(listenHandle);
  160.         llSetText ("",<1,1,1>,1.0);
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement