User:Talia Tokugawa/scripts/DialogMenu

From Second Life Wiki
Jump to: navigation, search

This is just an example dialog menu setup specifically for the owner of the item. Features "remenu", extending time out, random high channel listeners.

<lsl> key owner; integer listenChan; integer listener; integer count; menu() {

   listenChan=(integer)llFrand(899999) + 100000;
   listener=llListen(listenChan, "", owner, "");
   llDialog(owner, "Please select an option:", ["Option A", "Option B", "Done"], listenChan);
   count=10;
   llSetTimerEvent(3.0);
   

}

default {

   listen(integer c, string n, key id, string m)
   {
       llListenRemove(listener);
       if (c==listenChan&&id==owner)
       {
           //do stuff with option replies    
           if (m=="Done") return;
           else
           {
               if (m=="Option A") //Do something here 
               else if (m=="Option B") //Do something else here
               menu();
           }
       }
   }
   
   timer()
   {
       --count;
       if (count==0)
       {
           llListenRemove(listener);
           llSetTimerEvent(0.0);
       }
   }
   
   state_entry()
   {
       llWhisper(0, "/me are online.");
       owner=llGetOwner();
       menu();
   }
   
   on_rez(integer p)
   {
       if (owner!=llGetOwner()) llResetScript();        
   }
   touch_start(integer total_number)
   {
       if (llDetectedKey(0)==owner) menu();
   }


} </lsl>