Difference between revisions of "User:Talia Tokugawa/scripts/DialogMenu"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 44: Line 44:
         if (owner!=llGetOwner()) llResetScript();         
         if (owner!=llGetOwner()) llResetScript();         
     }
     }
 
     touch_start(integer itn) {
     touch_start(integer itn) {
         if (llDetectedKey(0)==owner) menu();
         if (llDetectedKey(0)==owner) menu();
     }
     }
  }
  }

Latest revision as of 13:48, 23 August 2023

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

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 ich, string sna, key kid, string sme) {
       llListenRemove(listener);
       if (ich==listenChan&&kid==owner) {
           //do stuff with option replies    
           if (sme=="Done") return;
           else {
               if (sme=="Option A") //Do something here 
               else if (sme=="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 isp) {
       if (owner!=llGetOwner()) llResetScript();        
   }

   touch_start(integer itn) {
       if (llDetectedKey(0)==owner) menu();
   }
}