Menu Script

From InWorldz Wiki
Jump to: navigation, search


Contributor: Tamia

  • Type: Script
  • Source: IW Forums: MENU SCRIPT-simple
  • Description: An elementary script to create and act on dialogs. This can be the nucleus for a larger project controlled by a dialog box.

key id;
// u can change this to get a different message in your menu ^_^
string mess = "This is the message in the blue menu";
//these are the options.. edit below for what the commands do  ^_^... keep the exit button.. dont mod it unless u know what ur doin.. i have it there for ppl to click it to close the listener.... cuts lag
list menu = ["Button1","Button2","Button3","EXIT"];
integer chan;
integer h;

init()
{
   llListenRemove(h);
   key id;
   h = llListen(chan, "",id, "");
}

default
{
   state_entry()
   {
   }

   touch_start(integer total_number)
   {
       id = llDetectedKey(0);
       chan = llFloor(llFrand(100000.0)) + 1000;
       init();
       llDialog(id,mess,menu,chan);
   }

   listen( integer channel, string name, key id, string message )
   {
       // okay.. change the  words in message = "" to match ur buttons up there..
       // (ex: message == "Button1") hehe
       if (message == "Button1")
       {
           // put your commands here
           llWhisper(0,"This is Button1");
           llListenRemove(h);         
       }       
       if (message == "Button2")
       {
           llWhisper(0,"This is Button2");
           llListenRemove(h);         
       }         
       if (message == "Button3")
       {
           llWhisper(0,"This is Button3");
           llListenRemove(h);         
       }   
       // dont mod the exit unless u wanna add like a message ^_^
       if (message == "EXIT")
       {
           llListenRemove(h);         
       }
   }
}