Advertisement
isnorden

Texture change menu

Sep 23rd, 2018
1,260
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //______Change Texture Menu___Alicia Stella______
  2. //__________last modifed__May 2009___________
  3. //_____more scripts: www.aliciastella.com_____
  4.  
  5. //Drop this script into an object with up to 22 textures inside.
  6.  
  7. //When anyone Touches they will get a menu with all the textures available. Button names in menu will be first 10 characters from that item's name.
  8.  
  9. //NOTE: Texture Names may not exceed 24 characters or script error and menu fails.
  10.  
  11.  
  12. integer side = ALL_SIDES; //ALL_SIDES or any face number 0 through 5
  13.  
  14. list texture_list;
  15. list texture_list2;
  16. key user = NULL_KEY;
  17.  
  18. composelist()
  19. {
  20.     integer currenttexture = 0;
  21.     integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE);
  22.    
  23.     if(totaltextures > 0 & totaltextures <= 12)
  24.     {
  25.         texture_list = [];
  26.         do
  27.         {
  28.             texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
  29.             currenttexture++;
  30.         }
  31.         while (currenttexture > 0 & currenttexture < totaltextures);
  32.     }
  33.    
  34.     if(totaltextures > 12 & totaltextures <= 22)
  35.     {
  36.         texture_list = ["Next Page"];
  37.         do
  38.         {
  39.             texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
  40.             currenttexture++;
  41.         }
  42.         while (currenttexture > 0 & currenttexture < 11);
  43.        
  44.         texture_list2 = ["Last Page"];
  45.         do
  46.         {
  47.             texture_list2 = texture_list2 + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
  48.             currenttexture++;
  49.         }
  50.         while (currenttexture >= 11 & currenttexture < totaltextures);
  51.     }
  52.    
  53.     if(totaltextures > 22)
  54.     {
  55.         llWhisper(0, "You may only have a maximimum of 22 Textures. Please remove any extra ones.");
  56.     }
  57.     if(totaltextures == 0)
  58.     {
  59.         llWhisper(0, "Please add up to 22 Textures inside this object.");
  60.     }
  61. }
  62.  
  63.  
  64. //The Menu
  65. integer menu_handler;
  66. integer menu_channel;
  67. menu(key user,string title,list texture_list)
  68. {
  69.     menu_channel = (integer)(llFrand(99999.0) * -1); //random channel
  70.     menu_handler = llListen(menu_channel,"","","");
  71.     llDialog(user,title,texture_list,menu_channel);
  72.     llSetTimerEvent(30.0); //menu channel open for 30 seconds
  73. }
  74.  
  75. default
  76. {
  77.     state_entry()
  78.     {
  79.         composelist(); //make list from inventory textures
  80.     }
  81.  
  82.     touch_start(integer total_number)
  83.     {
  84.         user = llDetectedKey(0);
  85.         menu(user,"\n\nPlease select one below.",texture_list);
  86.     }
  87.    
  88.     listen(integer channel,string name,key id,string message)
  89.     {
  90.         if (channel == menu_channel)
  91.         {
  92.             llSetTimerEvent(0.0);
  93.             llListenRemove(menu_handler);
  94.             if(message == "Next Page")
  95.             {
  96.                 menu(user,"\n\nPlease select one below.",texture_list2);
  97.             }
  98.             else if(message == "Last Page")
  99.             {
  100.                 menu(user,"\n\nPlease select one below.",texture_list);
  101.             }
  102.             else
  103.             {
  104.                 llSetTexture(message, side);
  105.             }
  106.         }
  107.     }
  108.    
  109.     timer() //Close the Menu Listen or we'll get laggy
  110.     {
  111.         llSetTimerEvent(0.0);
  112.         llListenRemove(menu_handler);
  113.     }
  114.    
  115.     changed(integer change)
  116.     {
  117.         if (change & CHANGED_INVENTORY) //inventory has changed
  118.         {
  119.             llSleep(0.5);
  120.             composelist(); //rebuild the list
  121.         }
  122.     }
  123. }
Advertisement
RAW Paste Data Copied
Advertisement