Difference between revisions of "DialogPlus"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|func_desc=Creates a dialog menu for '''storing more then 12 buttons''', very useful for Inventory items, Scanners, and just huge lists.
|func_desc=Creates a dialog menu for '''storing more then 12 buttons''', very useful for Inventory items, Scanners, and just huge lists.
|func_footnote=''''CurMenu'''' will take place of an integer menuindex.<br />This requires a Listen Event when using DialogPlus to allow the Back and Next button to work.
|func_footnote=''''CurMenu'''' will take place of an integer menuindex.<br />This requires a Listen Event when using DialogPlus to allow the Back and Next button to work.
See also: [[llDialog]]
|spec=<lsl>
|spec=<lsl>
//Created by Ugleh Ulrik
//Created by Ugleh Ulrik
Line 36: Line 35:
</lsl>
</lsl>
|examples=<lsl>
|examples=<lsl>
//remember to put the Specification section above here
//Created by Ugleh Ulrik
//Created by Ugleh Ulrik
//List2DialogPlus Example
//List2DialogPlus Example
Line 74: Line 74:


<lsl>
<lsl>
//remember to put the Specification section above here
//Created by Ugleh Ulrik
//Created by Ugleh Ulrik
//Inventory2DialogPlus Example
//Inventory2DialogPlus Example

Revision as of 21:57, 23 May 2010

Summary

Function: DialogPlus( key avatar, string message, list buttons, integer CurMenu, integer );

Creates a dialog menu for storing more then 12 buttons, very useful for Inventory items, Scanners, and just huge lists.

• key avatar
• string message message to be displayed
• list buttons button labels
• integer CurMenu Parsed menu index.
• integer

'CurMenu' will take place of an integer menuindex.
This requires a Listen Event when using DialogPlus to allow the Back and Next button to work.

Specification

<lsl> //Created by Ugleh Ulrik //This sort of script should cost, but for you free :) integer menuindex; DialogPlus(key avatar, string message, list buttons, integer channel, integer CurMenu) {

   if (llGetListLength(buttons) >12){
   list lbut = buttons;
   list Nbuttons = [];
   if(CurMenu == -1)
   {
       CurMenu = 0;
       menuindex = 0;
   }
   if((Nbuttons = (llList2List(buttons, (CurMenu * 10), ((CurMenu * 10) + 9)) + ["Back", "Next"])) == ["Back", "Next"])
       DialogPlus(avatar, message, lbut, channel, menuindex = 0);
   else
   {
       llDialog(avatar, message, Nbuttons, channel);
   }

}else{

   llDialog(avatar, message, buttons, channel);

} } </lsl>

Examples

<lsl> //remember to put the Specification section above here //Created by Ugleh Ulrik //List2DialogPlus Example integer channel = -900;//Here we set the Dialog Channel integer listen_handle; list The_List = ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7", "Option 8",

"Option 9", "Option 10", "Option 11", "Option 12", "Option 13", "Option 14", "Option 15", "Option 16", "Option 17",
"Option 18", "Option 19", "Option 20"];//Here we make a huge list for an example

default {

   touch_start(integer total_number)
   {
        listen_handle = llListen(channel, "",llGetOwner(),"");//We set a listen for only the owner
        DialogPlus(llGetOwner(), "Select an Option", The_List, channel, menuindex = 0);//Touch_Start we issue menuindex as 0 inside of the function itself
   }
   
    listen(integer chan, string name, key id, string msg){//We need a listen for the dialog itself, but as well as the Back/Next button.
        if(msg == "Next")
       {
           //If they clicked Next it will go to the next dialog window
           DialogPlus(llGetOwner(), "Select an Option", The_List, channel, ++menuindex);
           //++menuindex will turn menuindex plus 1, making it give the next page.
       }
       else if(msg == "Back")
       {
           //if they clicked back it will go to the last dialog window.
            DialogPlus(llGetOwner(), "Select an Option", The_List, channel, --menuindex);
           //--menuindex will turn menuindex minus 1, making it give the previous page.
       }else{
           //If they choose anything besides Back/Next it will be in this section
           llListenRemove(listen_handle); //Be Safe
           llSay(0,"Your choice was "+ msg);//Example used, change to whatever you wish.
   }
   }

} </lsl>

<lsl> //remember to put the Specification section above here //Created by Ugleh Ulrik //Inventory2DialogPlus Example integer channel = -900;//Here we set the Dialog Channel integer listen_handle; list InventoryList; default {

   touch_start(integer total_number)
   {
       InventoryList = [];
       integer i;
       integer a = llGetInventoryNumber(INVENTORY_ALL);
       do
       InventoryList += [TrimStringToLength(llGetInventoryName(INVENTORY_ALL, i),23)];
       while (a>++i);
        listen_handle = llListen(channel, "",llGetOwner(),"");//We set a listen for only the owner
        DialogPlus(llGetOwner(), "Select an Option", InventoryList, channel, menuindex = 0);//Touch_Start we issue menuindex as 0 inside of the function itself
   }
   
    listen(integer chan, string name, key id, string msg){//We need a listen for the dialog itself, but as well as the Back/Next button.
        if(msg == "Next")
       {
           //If they clicked Next it will go to the next dialog window
           DialogPlus(llGetOwner(), "Select an Option", InventoryList, channel, ++menuindex);
           //++menuindex will turn menuindex plus 1, making it give the next page.
       }
       else if(msg == "Back")
       {
           //if they clicked back it will go to the last dialog window.
            DialogPlus(llGetOwner(), "Select an Option", InventoryList, channel, --menuindex);
           //--menuindex will turn menuindex minus 1, making it give the previous page.
       }else{
           //If they choose anything besides Back/Next it will be in this section
           llListenRemove(listen_handle); //Be Safe
           llSay(0,"Your choice was "+ msg);//Example used, change to whatever you wish.
   }
   }

}

</lsl>