Advertisement
StarWolff2000

AutoPop Menu

Oct 10th, 2018
1,047
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // the problem is in the SubMenu_List(key id) function
  2. // This menu worked before I started to add another if/else
  3. // the function was like:
  4. // function()
  5. //       some settings
  6. //            some stuff
  7. // show dialog box
  8.  
  9. // I am trying to re-use the function for multiple menus (so it will run this function for one main menu button, which would populate a submenu, run it again for another main menu button, which would populate a second submenu...etc - and I need it to NOT run that function when the main menu is showing
  10.  
  11. // so I changed the SubMenu_List(key id) function like this:
  12.  
  13. // function()
  14. //       some settings
  15. // if(this is the main menu)
  16. // {
  17. //    do some stuff
  18. // }
  19. // else
  20. // {
  21. //            some stuff
  22. // }
  23. // show dialog box
  24.  
  25.  
  26.  
  27.  
  28.  
  29. // USER SETTABLE PARAMETERS
  30. float MENU_TIMEOUT = 25; // Time in seconds before menu times out & listener is removed
  31.  
  32. // Menu parameters
  33. integer menu_channel ;
  34. integer options_channel;
  35. integer menu_handler;
  36. integer options_handler;
  37. //list Menu_00 = ["INFO/About","Admin","Close Menu"];
  38. //TEMPORARY MENU
  39. string Menu_00_Caption = "Select a Category";
  40. list Menu_00 = ["INFO/About","Admin","Close Menu","Ground","Horizon","Sky","Sun/Moon","Underground","Themes"];
  41. list Menu_NAV_butt = ["<==","Themes","==>"];
  42. list Menu_THM = ["These","are","dummy","theme","names"," - ","Don't","click","these"];
  43.  
  44.  
  45.  
  46. // !!!!!!!!
  47. // TEMP specifying this - THE ACTUAL CODE WOULD USE THIS
  48. // to flag which type of Items we're listing
  49. integer Menu_Sub_ID = 0;
  50. list Menu_Sub_Names = ["Main Menu","Ground","Horizon","Sky","Sun/Moon","Underground","Themes"];
  51. string Menu_Sub_Caption = "Main Menu";
  52. // CHANGE THIS: When a SubMenu is selected, set this flag
  53.  
  54.  
  55. //Misc parameters
  56. string aviname;
  57. integer Item_CountPointer = 0;
  58. integer Item_CountCurrentPos = 0;
  59. integer Item_Total;  // number of sounds in the prim's inventory
  60. float sound_volume = 1.0;
  61. string lastsound;
  62.  
  63. remove_listens()
  64. {
  65.     llSetTimerEvent(0.0);
  66.     llListenRemove(menu_handler);
  67.     llListenRemove(options_handler);    
  68. }
  69.  
  70. // opens menu channel and displays dialog
  71. SubMenu_List(key id)
  72. {
  73.     remove_listens();
  74.     menu_channel = -(integer) (llFrand(100000000) + 100000);
  75.     options_channel = menu_channel + 1;
  76.     menu_handler = llListen(menu_channel, "", NULL_KEY, "");
  77.     options_handler = llListen(options_channel,"",NULL_KEY,"");
  78.     llSetTimerEvent(MENU_TIMEOUT);
  79.  
  80. //-SKIP Listing SubMenus~BEG//
  81. // if this is the main menu...
  82. // ------------------------------------------------------------------2FIX this 'if' section
  83.  if ((Menu_Sub_Names(Menu_Sub_ID)) == 0)
  84.  {
  85. // ...then display the main menu
  86.     Menu_Sub_Caption = Menu_00_Caption;
  87.     Menu_Sub = Menu_00;
  88.  }
  89. // ...and skip the SubMenus Listing
  90. // Otherwise, List SubMenus
  91.  else
  92.  {
  93.  
  94.     list Menu_Sub = [];
  95.     // count the Items in the prim to see if we need pages
  96.     Item_Total = llGetInventoryNumber(INVENTORY_TEXTURE);
  97.     if (Item_Total < 9)
  98.     {
  99.         for (Item_CountPointer = 0; Item_CountPointer < Item_Total; Item_CountPointer++)
  100.         {
  101.             Menu_Sub += llGetInventoryName(INVENTORY_TEXTURE, Item_CountPointer);
  102.         }
  103.         Menu_Sub = Menu_00 + Menu_NAV_butt + Menu_Sub;
  104.  
  105.     }
  106.     else
  107.     {
  108.         for (Item_CountPointer = 6 * Item_CountCurrentPos; Item_CountPointer < (6 + (6 * Item_CountCurrentPos)) ; Item_CountPointer++)
  109.         {
  110.  
  111.             // check to make sure name <= 24, or else the menu will not work.
  112.             string Item_Name = llGetInventoryName(INVENTORY_TEXTURE, Item_CountPointer);
  113.             if ( llStringLength(Item_Name) >24)
  114.             {
  115.                 llOwnerSay("NOTICE");
  116.                 llOwnerSay("Item Name: " + Item_Name + " is too long. Item Names can not be longer than 24 characters");
  117.             }
  118.             else
  119.             {
  120.                 if (Item_CountPointer < Item_Total)
  121.                 {
  122.                     Menu_Sub += Item_Name;
  123.                 }
  124.             }
  125.         }
  126.         Menu_Sub = Menu_00 + Menu_NAV_butt + Menu_Sub;
  127.     }
  128.  
  129. // }
  130.     Menu_Sub_Caption = "Select a " + llList2String(Menu_Sub_Names, Menu_Sub_ID) + " Item";
  131.     llDialog(id, Menu_Sub_Caption, Menu_Sub, menu_channel);
  132.  
  133. //-SKIP Listing SubMenus~END//
  134.  }
  135.  
  136. }
  137. //---GET SUB LIST END--//
  138.  
  139.  
  140. default
  141. {
  142.     state_entry()
  143.     {
  144.  
  145.     }
  146.  
  147.     on_rez(integer num)
  148.     {
  149.         llResetScript();
  150.     }
  151.  
  152.     timer()
  153.     {
  154.         llSetTimerEvent(0.0);
  155.         remove_listens();
  156.     }
  157.  
  158.     touch_start(integer total_number)
  159.     {
  160.         aviname = llDetectedName(0);
  161.         Item_CountCurrentPos = 0;
  162.         // display the dialog
  163.         SubMenu_List(llDetectedKey(0));
  164.     }
  165.  
  166.     listen(integer channel, string name, key id, string message)
  167.     {
  168.         // THIS WILL BE NEEDING TO CHANGE TO A FLAG when you select WHICH menu you're talking to/about
  169.         Menu_Sub_ID = 1;
  170. llSay(0,llList2String(Menu_Sub_Names, Menu_Sub_ID));
  171.  
  172.  
  173.         if (channel == menu_channel)
  174.         {
  175.             if (message == "==>")
  176.             {
  177.                 if(Item_CountCurrentPos < (llRound((float)Item_Total/6)) ) Item_CountCurrentPos ++;
  178.                 SubMenu_List(id);
  179.             }
  180.             else if (message == "<==")
  181.             {
  182.                 Item_CountCurrentPos--;
  183.                 if (Item_CountCurrentPos < 0) Item_CountCurrentPos = 0;
  184.                 SubMenu_List(id);
  185.             }
  186.             else if (message == "Themes")
  187.             {
  188.                 llSetTimerEvent(MENU_TIMEOUT);
  189.                 Menu_Sub_Caption = "Select a " + llList2String(Menu_Sub_Names, Menu_Sub_ID) + " Item";
  190.                 llDialog(id, Menu_Sub_Caption, Menu_THM, options_channel);
  191.             }
  192.             else
  193.             {
  194.                 llPlaySound(message, sound_volume);  // Play the sound
  195.                 lastsound = message;
  196.                 SubMenu_List(id);
  197.             }
  198.         }
  199.         if (channel == options_channel)
  200.         {
  201.             if(message == "Main Menu")  // no entry in options menu for this so it is currently not used
  202.             {
  203.                 Item_CountCurrentPos = 0;
  204.                 SubMenu_List(id);
  205.             }
  206.             else if(message == "Admin")
  207.             {
  208.                 llSetTimerEvent(MENU_TIMEOUT);
  209.                 llTextBox(id,"Enter Sound Volume\nMinimum = 0.0\nMaximum = 1.0",options_channel);
  210.             }
  211.  
  212.             else // sound volume setting
  213.             {
  214.                 sound_volume = (float)message;
  215.                 if (sound_volume > 1.0) sound_volume = 1.0;
  216.                 if (sound_volume < 0.0) sound_volume = 0.0;
  217.                 Item_CountCurrentPos =  0;
  218.                 SubMenu_List(id);
  219.             }
  220.  
  221.         }
  222.     }
  223. }
Advertisement
RAW Paste Data Copied
Advertisement