Low Lag menu with brief listen that closes when not in use. Use this simple menu in your own scripts!
list MENU_MAIN = ["Hello", "Goodbye"]; //up to 12 in list
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
llListenRemove(menu_handler); //BugFix 5/2008
menu_channel = (integer)(llFrand(99999.0) * -1);
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(30.0); //how long to wait for user to press a button before giving up and closing listen
}
default
{
state_entry()
{
//nada
}
touch_start(integer total_number)
{
menu(llDetectedKey(0), "nText for Menu.", MENU_MAIN);
}
listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel)
{
llListenRemove(menu_handler); //close listen
llSetTimerEvent(0); //stop timeout timer
if (message == "Hello")
{
llSay(0, "World");
}
else if (message == "Goodbye")
{
llSay(0, "Fine, be that way.");
}
//else if (message == "Button")
//{
//do something
//}
}
}
timer() //VERY IMPORTANT menu timeout
{
llListenRemove(menu_handler); //close listen
llSetTimerEvent(0); //stop timeout timer
}
}
|