Dialog with more than 12 buttons

From Second Life Wiki
Revision as of 13:57, 8 April 2007 by Matthias Gasser (talk | contribs) (A way to put more than 12 buttons in a dialog - scrolling buttons)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Hi

i searched a long time for a way to put more than 12 buttons in a dialog. here is my way:

key user; integer channel = 0; //insert a channel here - 0 is public list targets; string selected; //the selected option is saved in this variable integer site = 1; integer lala() {

       integer length = llGetListLength(targets);
       list show; //is simple buffer to safe what is shown on this page
       integer start_to_show = (site - 1)*10;
       integer i;
       integer end_to_show = start_to_show + 10;
       if(end_to_show > length)
       {
           end_to_show = length;
       }
       i = start_to_show;        
       while(i < end_to_show)
       {
           show += llList2String(targets,i);
           i++;
       }
       if(site != 1) 
       {
           show += ["<<<"]; 
       }
       if(end_to_show != length)
       {
           show += [">>>"];
       }        
       llDialog(user,"lala",show,channel);
       return 1;

} default {

   state_entry()
   {
       llSay(0, "Ready!");
   }
   touch_start(integer total_number)
   {
       user = llDetectedKey(0);
       targets = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]; // here are the buttons to display
       state show_targets;
   }

}

state show_targets {

   state_entry()
   {
       lala();
       llListen(channel,"",user,"");
   }
   listen( integer channel, string name, key id, string message )
   {
       if(message == "<<<")
       {
           site -= 1;
           lala();
       }
       else if(message == ">>>")
       {
           site += 1;
           lala();
       }
       else
       {
           selected = message;
           state default;
       }
   }

}

ok, i say it too, i was not so good in "find the right name for your funktion, but it works.

the selected option is saved in the string "selected".

I hope you can understand my code and my bad english and this is helpfull for you

--Matthias Gasser 13:57, 8 April 2007 (PDT)

PS: damn, how can i put my code in this nice boxes are displayed everywere?