Advertisement
giratina1999

Dialog help :)

Feb 3rd, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // need help asap got a dialog script but not sure where to add what i want b coz im making a tardis i have added the summon around infront and demat buttons but im not sure where to add the comands to when click that option do this for that button
  2.  
  3. integer    gActionsPerPage = 9;          
  4. list       gListActions = ["Summon","Around", "Demat"];
  5.  
  6.  
  7. integer    gTotalActions;            
  8. integer    gPage;                  
  9. integer    gMaxPage;        
  10. integer    gChan;                  
  11. key        gUser;                  
  12.  
  13. BuildDialogPage(key user)
  14. {
  15.     // Build a dialog menu for current page for given user
  16.     integer start = gActionsPerPage * gPage;       // starting offset
  17.     list buttons = [ "<<", " ", ">>" ];
  18.     if (gActionsPerPage == 10)           buttons = [ "<<", ">>" ];
  19.     else if (gActionsPerPage > 10)       buttons = [];          // No room for paging buttons
  20.  
  21.     // 'start + gActionsPerPage -1' might point beyond the end of the list -
  22.     // - but LSL stops at the list end, without throwing a wobbly
  23.     buttons += llList2List(gListActions, start, start + gActionsPerPage - 1);
  24.     llDialog(user, "\nPage " + (string) (gPage+1) + " of " + (string) (gMaxPage + 1) + "\n\nChoose an action", buttons, gChan);
  25.     llSetTimerEvent(60);              
  26.  
  27. default
  28. {
  29.     state_entry()
  30.     {
  31.         gTotalActions = (gListActions != [] );        // get length of action list
  32.  
  33.         // Validate 'ActionsPerPage' value
  34.         if (gActionsPerPage < 1 || gActionsPerPage > 12)
  35.         {
  36.             llOwnerSay("Invalid 'gActionsPerPage' - must be 1 to 12");
  37.             return;
  38.         }
  39.  
  40.         // Compute number of menu pages that will be available
  41.         gMaxPage = (gTotalActions - 1) / gActionsPerPage;
  42.         if (gActionsPerPage > 10)
  43.         {
  44.             gMaxPage = 0;
  45.             if (gTotalActions > gActionsPerPage)
  46.             {
  47.                 llOwnerSay("Too many actions in total for this ActionsPerPage setting");
  48.                 return;
  49.             }
  50.         }
  51.  
  52.         // Compute a negative communications channel based on prim UUID
  53.         gChan = 0x80000000 | (integer) ( "0x" + (string) llGetKey() );
  54.         state ready;
  55.     }
  56. }
  57. state ready
  58. {
  59.     touch_end(integer total_number)
  60.     {
  61.         gUser = llDetectedKey(0);
  62.         state busy;                                    
  63.         // Changing state sets the application to a busy condition while one user is selecting from the dialogs
  64.         // In the event of multiple 'simultaneous' touches, only one user will get a dialog
  65.     }
  66. }
  67. state busy
  68. {
  69.     state_entry()
  70.     {
  71.         llListen(gChan, "", gUser, "");                // This listener will be used throughout this state
  72.         gPage = 0;
  73.         BuildDialogPage(gUser);                        // Show  Page 0 dialog to current user
  74.     }
  75.     listen (integer chan, string name, key id, string msg)
  76.     {
  77.         if (msg == "<<" || msg == ">>")                   // Page change ...
  78.         {
  79.             if (msg == "<<")        --gPage;              // Page back
  80.             if (msg == ">>")        ++gPage;              // Page forward
  81.             if (gPage < 0)          gPage = gMaxPage;     // cycle around pages
  82.             if (gPage > gMaxPage)   gPage = 0;
  83.             BuildDialogPage(id);
  84.             return;
  85.         }
  86.         if (msg != " ")                                  // no action on blank menu button
  87.         {
  88.             // User has selected an action from the menu
  89.             llRegionSayTo(id, 0, "You chose action <" + msg + ">");
  90.         }
  91.         state ready;         // changing state will release ANY and ALL open listeners
  92.     }
  93.     timer()
  94.     {
  95.         llRegionSayTo(gUser, 0, "Too slow, menu cancelled");
  96.         state ready;
  97.     }
  98.     state_exit()
  99.     {
  100.         llSetTimerEvent(0);          // would be dangerous to leave a dormant timer
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement