Difference between revisions of "Dialog with more than 12 buttons"

From Second Life Wiki
Jump to navigation Jump to search
(A way to put more than 12 buttons in a dialog - scrolling buttons)
 
m (switched code tags to pre tags)
 
Line 3: Line 3:
i searched a long time for a way to put more than 12 buttons in a dialog. here is my way:
i searched a long time for a way to put more than 12 buttons in a dialog. here is my way:


<code>key user;
<pre>key user;
integer channel = 0; //insert a channel here - 0 is public
integer channel = 0; //insert a channel here - 0 is public
list targets;
list targets;
Line 76: Line 76:
         }
         }
     }
     }
}</code>
}</pre>


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


PS: damn, how can i put my code in this nice boxes are displayed everywere?
PS: damn, how can i put my code in this nice boxes are displayed everywere?
:Use the <nowiki><pre></nowiki> tags until(if ever) the <nowiki><lsl></nowiki> tags are functional. I've changed yours already.
:--[[User:DoteDote Edison|DoteDote Edison]] 18:05, 8 April 2007 (EDT)

Latest revision as of 15:09, 8 April 2007

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?

Use the <pre> tags until(if ever) the <lsl> tags are functional. I've changed yours already.
--DoteDote Edison 18:05, 8 April 2007 (EDT)