|
tucor Capalini
Registered User
Join date: 18 Jun 2007
Posts: 44
|
10-05-2008 18:57
I am trying to figure out a way to have a dialog with an *infinitie number of pages based on however many textures are contained within a prim. I have one way of doing it, but it really doesnt seem right. I made 15 lists and had them defined by llGetInventoryName...... with the thought that I could make enough lists to cover everything possible. Not exactly efficint, and kinda feels like duct tape and bailing wire to me. I tried some other ways, and everything logical that I come up with doesnt quite function. If anyone has any pointers to more information I greatly appreciate it! TIA
*infinite relative to the number of items that can be contained inside a prims CONTENTS
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-05-2008 20:07
Usually this is done by using at least some kind of "Next" button (but often "Next", "Prev", and "Cancel"  . Given the limit of 12 buttons per dialog, it is usually easiest to implement 9-10 real choices per page and have 2-3 special buttons (for simplicity I suggest using the same number of choices even when you don't need all 2/3 special buttons, so that the page and choice numbers can be calculated using simple multiplication and division: e.g. index/9). I often encode the next/previous page in the name of the button so that I don't have to remember any state in the script itself. For example, page 2 might have the buttons ">Page 1" and ">Page 3", and the script will test whether the response has the prefix ">Page " and strip the number off the end to display the appropriate page of choices if so. Otherwise it'll assume the answer is a legitimate choice.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-05-2008 20:33
Create one small list with the next and prev buttons defined. Create one long list with everything else & define an integer (x for example)as 0 and use it as a place holder.
If you click "NEXT" then adds 10 to the integer and builds the button list using llList2List(long_list, x, x + 10). Then add in the "NEXT" & "PREV" list to complete the buttons.
"PREV" will subtract 10 from x etc, etc, etc.
You will have to add in a check for list length.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-05-2008 23:22
if you check in the library on lsl wiki, there is a texture menu there
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-06-2008 00:40
From: tucor Capalini I am trying to figure out a way to have a dialog with an *infinitie number of pages based on however many textures are contained within a prim. CONTENTS I've just made one of these, based on the examples at http://lslwiki.net/lslwiki/wakka.php?wakka=ZenMondo . Two prims. Root, which contains your textures and this script, is used to display the textures: /////////////////////////// // This work is licensed under the Creative Commons Attribution-Noncommercial-Share // Alike 3.0 License. To view a copy of this license, visit // http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative // Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. // // Attribution: // If unmodified you must keep the filename intact // If a derivative work you must say "Based on the CodePoetry of ZenMondo Wormser"
integer object_counter=0; list inventory_list = []; list menu_list = [];
integer menu_page; integer last_menu;
integer handle; integer UserChan = -11811;
key current_user = NULL_KEY;
integer using; //Functions
//Compact function to put buttons in "correct" human-readable order ~ Redux //Taken from http://lslwiki.net/lslwiki/wakka.php?wakka=llDialog list order_buttons(list buttons) { return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10); }
//Function to Build the two lists we will use // Could have put it all in state_entry but may be a handy function // to use in another similar script so I put it here. BuildLists() { integer counter=0; integer inventory_num = llGetInventoryNumber(INVENTORY_TEXTURE); while(counter < inventory_num) { string object_name = llGetInventoryName(INVENTORY_TEXTURE, counter); inventory_list = (inventory_list=[]) + inventory_list + object_name; menu_list = (menu_list=[]) + menu_list + [(string) (++counter) + ")" + object_name]; //Incrimenting the the counter in this line. Probably bad practice //But it solves two problems, incrimenting the counter in the loop // and making a human readale list startign at "1" instead of "0"
} if(counter % 9 == 0) //Multiples of 9 won't round down right. { --counter; } last_menu = llFloor(counter / 9.0); //I say 9.0 so it treats it like a float // and will round down correctly. }
//Function to Display the pages of the Menu // Instead of defining my menus ahead of time // (and in so doing putting a limit on the number of items) // I build the pages of the menu dynamicaly DisplayMenu(key id) { //These are the buttons, they will be numbers // Based on what page of the menu we are on. string b1 = (string) (menu_page *9 +1); string b2 = (string) (menu_page *9 +2); string b3 = (string) (menu_page *9 +3); string b4 = (string) (menu_page *9 +4); string b5 = (string) (menu_page *9 +5); string b6 = (string) (menu_page *9 +6); string b7 = (string) (menu_page *9 +7); string b8 = (string) (menu_page *9 +8); string b9 = (string) (menu_page *9 +9); list menu = [b1, b2, b3, b4, b5, b6, b7, b8, b9, "<<PREV", "Finished", "NEXT>>"]; //will use the order_buttons function to put these in a good order for llDialog list menu_text = llList2List(menu_list, menu_page * 9, menu_page * 9 + 8); //This is the part of the list for menu text for this page. integer menu_length = llGetListLength(menu_text); if(menu_length < 9) //Don't Need all the buttons { menu = llDeleteSubList(menu, menu_length, 8); //Trim the menu buttons } llDialog(id, llDumpList2String(menu_text, "\n"), order_buttons(menu), UserChan); //Display the Menu }
default { state_entry() { menu_page = 0; UserChan = -((integer)llFrand(2147483646.0) + 1); //Choose a random negative channel to use to avoid crossttalk with other books
BuildLists(); }
touch_start(integer total_number) { current_user = llDetectedKey(0); using = TRUE; handle = llListen(UserChan, "", current_user, ""); llSetTimerEvent(90); //90 Second limit to make a choice or reset if walk away DisplayMenu(current_user); } listen(integer channel, string name, key id, string message) { if(message == "<<PREV") { llSetTimerEvent(0); llSetTimerEvent(90); menu_page--; if(menu_page == -1) { menu_page = last_menu; } DisplayMenu(current_user); } else if(message == "NEXT>>") { llSetTimerEvent(0); llSetTimerEvent(90); menu_page++; if(menu_page > last_menu) { menu_page = 0; } DisplayMenu(current_user); } else if (message == "Finished") { llSetTimerEvent(0); llListenRemove(handle); using = FALSE; current_user = NULL_KEY; menu_page = 0; } else //Patron Chose a Number { llSetTimerEvent(0); llListenRemove(handle); integer get_item = (integer) message; get_item--; //Humans like to count from 1, but computers like 0 better. llSetTexture( llList2String(inventory_list, get_item), ALL_SIDES); handle = llListen(UserChan, "", current_user, ""); llSetTimerEvent(90); //90 Second limit to make a choice or reset if walk away DisplayMenu(current_user);
} } timer() { llSetTimerEvent(0); llListenRemove(handle); llDialog(current_user, "I'm sorry time has expired to make a menu choice." , ["OK"], 1181111811); using= FALSE; current_user = NULL_KEY; menu_page = 0; } link_message(integer sender_num, integer num, string str, key id) { llGiveInventory(id, llGetTexture(0)); } changed(integer change) { if(change & CHANGED_INVENTORY) { llResetScript(); } } }
Second prim (just a button to press if you want a copy of the texture) default {
touch_start(integer total_number) { key id = llDetectedKey(0); llMessageLinked(LINK_ALL_OTHERS, 0, "Boo", id); } }
I didn't really need a second, button, script, of course -- it would be just as easy to give the texture from a menu button, but I needed a prim with a notice on explaining how to use the device, so I thought the notice might as well include "click me for a copy of the texture".
|
|
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
|
10-06-2008 01:00
You can do the above relatively easily with multimenu (which I posted a month ago and is in the library). It automatically creates menu pages with next/back buttons for as many items as you wish.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-06-2008 01:55
From: Jesse Barnett Create one small list with the next and prev buttons defined. Create one long list with everything else & define an integer (x for example)as 0 and use it as a place holder.
If you click "NEXT" then adds 10 to the integer and builds the button list using llList2List(long_list, x, x + 10). Then add in the "NEXT" & "PREV" list to complete the buttons.
"PREV" will subtract 10 from x etc, etc, etc.
You will have to add in a check for list length. One small issue with that implementation is that the script must remember 'x' between the llDialog() call and receiving the response, which isn't very friendly if the script must support multiple simultaneous users. If you use a prefix and encode the actual page numbers in the next/previous buttons then you don't have to do that and the menu basically becomes stateless as far as the script is concerned.
|