Devone Carter Posted December 10, 2013 Share Posted December 10, 2013 hi, this code is from the lsl library section,i spotted a problem, can anybody help fix it,it works fine until thiers 21 items in the listi`ll take pics to show you. list gNames = ["1","2","3","4","5","6","7", "8","9","10","11","12","13","14","15","16","17","18", "19","20","21"]; this is the second page when thiers twenty one items in the list,thier shouldnt be a >>> buttonhttp://s10.postimg.org/rpqxxw8w9/image.jpgso we have a third page which is blankhttp://s29.postimg.org/xenx81c6f/3page21.jpg // Simple Multipage Menu -- Rolig Loon -- August 2013 // The Menu routine in this script will parse your input list (gNames) into menu pages // of 12 buttons each, including a forward button and a back button, as appropriate. // It generates a page's buttons on demand, so that the list of button labels is // never more than 12 items long. // It does NOT trim potential menu items to fit the 25-character limit (or the // 12-character display limit), nor does it sort buttons or do other fancy things // that you are free to add for yourself. list gNames = ["A","B","C","D","E","F","G", "H","I","J","K","L","M","N","O","P","Q", "R","S","T","U","V","W","X","Y"]; // Your list of potential menu choices integer gMenuPosition; // Index number of the first button on the current page integer gLsn; // Dialog Listen Handle Menu() { integer Last; list Buttons; integer All = llGetListLength(gNames); if(gMenuPosition >= 9) //This is NOT the first menu page { Buttons += " <----"; } if (All > gMenuPosition+9) //If there are menu pages beyond this one .... { Buttons += " ---->"; } else // This is the last menu page { Last = TRUE; } if (All > 0) { integer b; integer len = llGetListLength(Buttons); // This bizarre test does the important work ...... for(b = gMenuPosition + len + Last - 1 ; (len < 12)&&(b < All); ++b) { Buttons = Buttons + [llList2String(gNames,b)]; len = llGetListLength(Buttons); } } gLsn = llListen(-12345,"","",""); llSetTimerEvent(10.0); llDialog(llGetOwner()," \n",Buttons,-12345); } default { touch_start(integer num) { llListenRemove(gLsn); gMenuPosition = 0; Menu(); } listen(integer channel, string name, key id, string msg) { llListenRemove(gLsn); llSetTimerEvent(0.0); if (~llSubStringIndex(msg,"---->")) { gMenuPosition += 10; Menu(); } else if (~llSubStringIndex(msg,"<----")) { gMenuPosition -= 10; Menu(); } else { //Do whatever the selected button directs..... your choice } } timer() { llSetTimerEvent(0.0); llListenRemove(gLsn); } } Link to comment Share on other sites More sharing options...
Ela Talaj Posted December 10, 2013 Share Posted December 10, 2013 I've an API for menu building which makes either single page or multi-page menus depending on the items number. It is listed in the Marketplace at https://marketplace.secondlife.com/p/Scripter-Resource-Kit-A/1932506 at a hefty price of L$0. Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 All it takes to get rid of that extra page is a little math. Try this... if(gMenuPosition >= 9) //This is NOT the first menu page { Buttons += " <----"; if((All - gMenuPosition) > 11) // This is not the last page { Buttons += " ---->"; } else // This IS the last page { Last = TRUE; } } else if (All > gMenuPosition+9) // This IS the first page, and there's more to follow { Buttons += " ---->"; } else // This is the only menu page { Last = TRUE; } Thanks for noticing this. Link to comment Share on other sites More sharing options...
Devone Carter Posted December 10, 2013 Author Share Posted December 10, 2013 cheers, problem occurs again if you only have 11 items in the list Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2013 Share Posted December 10, 2013 Oh, well then.... Did you try doing exactly the same trick again? else if (All > gMenuPosition+9) // This IS the first page { if((All - gMenuPosition) > 11) // There are more pages to follow { Buttons += " ---->"; } else // This IS the last page { Last = TRUE; } } What the ....? The code pasting widget is busted. :smileymad: Anyway, that works. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now