Advertisement
Almaren

Untitled

Jul 5th, 2019
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////////////////////////////////////////////////
  2. //
  3. //  Gateway Script
  4. //
  5. //  made for the =BB= Stellar Gateway Class for Builders Brewery
  6. //  by Wolf Song (wolfslied)
  7. //
  8. //  please do not give away with full permsissions
  9. //  Set it to no modify/no transfer in your own builds
  10. //
  11. //////////////////////////////////////////////////
  12.  
  13. ///////////////////////////
  14. // Global parameters
  15. ///////////////////////////
  16.  
  17.  
  18.  
  19. string msg = "Where do you want to go?"; //text in dialog window
  20.  
  21.  
  22.  
  23. // menu settings:
  24. string msgTimeout = "Sorry. Menu has timed out. Please try again.";
  25. float timeout= 20.0; //timeout for menu in seconds
  26.  
  27. // name of the landmark notecard
  28. string notecardName = "Destinations";
  29. //  lines on notecard should be in this format:
  30. //  Land Name (appears in menu) = SLurl
  31. //  Caution: Land names should not be longer than 12 characters or they won't be fully displayed
  32.  
  33. /////////////////////////////////////////////////////
  34. //  *** please ONLY change things below this line
  35. //  if you know what you're doing ***
  36. //  (or at least keep a backup copy of the script)
  37. /////////////////////////////////////////////////////
  38.  
  39. string primName;
  40.  
  41. integer channel;
  42. integer listenHandle;
  43. key id;
  44.  
  45. integer diaChoice;
  46. integer diaMax = 9;
  47. string prevPG = "< Page ";
  48. string nextPG = "> Page ";
  49. integer pageNum;
  50.  
  51. key ncID;
  52. integer notecardLine;
  53. list LandName;
  54. list destination_vector;
  55. vector dest;
  56. integer gAccessMode = 1; // Change who can use the teleporter: 1 - public, 2 - owner, 3 - group
  57. float gDelaySeconds = 1.0;
  58.  
  59. /////////////////////////////////////
  60. // custom calls
  61. ////////////////////////////////////
  62.  
  63. //debug
  64. say(string inputString)
  65. {
  66.     llOwnerSay(inputString);
  67. }
  68.  
  69. // open dialog
  70. openDialog(key ID, integer pageNum)
  71. {
  72.     list buttons;
  73.     integer firstChoice;
  74.     integer lastChoice;
  75.     integer prevPage;
  76.     integer nextPage;
  77.     string OnePage;
  78.     diaChoice = llGetListLength(LandName);
  79.     if (diaChoice <= 10) {
  80.         buttons = LandName;
  81.         OnePage = "Yes";
  82.     }
  83.     else {
  84.         integer nPages = (diaChoice+diaMax-1)/diaMax;
  85.         if (pageNum < 1 || pageNum > nPages) {
  86.             pageNum = 1;
  87.         }
  88.         integer firstChoice = (pageNum-1)*diaMax;
  89.         integer lastChoice = firstChoice+diaMax-1;
  90.         if (lastChoice >= diaChoice) {
  91.             lastChoice = diaChoice;
  92.         }
  93.         if (pageNum <= 1) {
  94.             prevPage = nPages;
  95.             nextPage = 2;
  96.         }
  97.         else if (pageNum >= nPages) {
  98.             prevPage = nPages-1;
  99.             nextPage = 1;
  100.         }
  101.         else {
  102.             prevPage = pageNum-1;
  103.             nextPage = pageNum+1;
  104.         }
  105.         buttons = llList2List(LandName, firstChoice, lastChoice);
  106.     }
  107.         list buttons01 = llList2List(buttons, 0, 2);
  108.         list buttons02 = llList2List(buttons, 3, 5);
  109.         list buttons03 = llList2List(buttons, 6, 8);
  110.         list buttons04;
  111.         if (OnePage == "Yes")
  112.         {
  113.             buttons04 = llList2List(buttons, 9, 11);
  114.         }
  115.         buttons = buttons04 + buttons03 + buttons02 + buttons01;
  116.         if (OnePage == "Yes")
  117.         {
  118.              buttons = []+ buttons;            
  119.         }
  120.         else
  121.         {
  122.             buttons =(buttons=[])+[prevPG+(string)prevPage, nextPG+(string)nextPage]+buttons;
  123.         }
  124.         llDialog(id, "Page "+(string)pageNum+"\n"+msg, buttons, channel);
  125. }
  126.  
  127. //remove listener
  128. CancelListen()
  129. {
  130.     llListenRemove(listenHandle);
  131.     llSetTimerEvent(0);
  132.     integer access_granted = FALSE;
  133. }
  134.  
  135.  
  136. default
  137. {
  138.      on_rez(integer start_param)
  139.     {
  140.         llResetScript();
  141.     }
  142.     state_entry()
  143.     {
  144.         channel = (integer)llFrand(DEBUG_CHANNEL)*-1;
  145.         primName = llGetLinkName(LINK_THIS);
  146.         if (llGetInventoryKey(notecardName) == NULL_KEY)
  147.         {
  148.             llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten.");
  149.             return;
  150.         }
  151.        
  152.         ncID = llGetNotecardLine(notecardName, notecardLine);
  153.         llSitTarget(<0.0, 0.0, 0.51>, ZERO_ROTATION);
  154.         llSetClickAction(CLICK_ACTION_SIT);
  155.        
  156.     }
  157.  
  158.     dataserver(key query_id, string data)
  159.     {
  160.         if (query_id == ncID)
  161.         {
  162.             if (data == EOF)
  163.                 say("Done reading notecard, found " + (string) notecardLine + " destinations.");
  164.             else
  165.             {                
  166.                 list param = llParseString2List(data, ["="], []);              
  167.                 string command = llStringTrim(llList2String(param, 0), STRING_TRIM);
  168.                 LandName +=command;
  169.                
  170.                 string value = llStringTrim(llList2String(param, 1), STRING_TRIM);
  171.                 destination_vector += value;
  172.                
  173.                 ++notecardLine;
  174.                 ncID = llGetNotecardLine(notecardName, notecardLine);
  175.             }
  176.         }
  177.     }
  178.    
  179.     changed (integer change)
  180.     {
  181.         if (change & CHANGED_INVENTORY)
  182.             llResetScript();
  183.    
  184.    
  185.         if (change & CHANGED_LINK)
  186.         {
  187.            key USER = llAvatarOnSitTarget();
  188.             integer access_granted = FALSE;
  189.            
  190.            
  191.            
  192.                    if (gAccessMode == 1)
  193.                    {
  194.                         access_granted = TRUE;
  195.                     }
  196.                     else if (gAccessMode == 2)
  197.                     {
  198.                          if (USER == llGetOwner())
  199.                          {
  200.                                 access_granted = TRUE;
  201.                          }
  202.                     }
  203.                      else if  (gAccessMode == 3)
  204.                      {
  205.                          if (llSameGroup(USER))
  206.                          {
  207.                             access_granted = TRUE;
  208.                          }
  209.                     }
  210.                     else
  211.                     {
  212.                          llUnSit(USER);
  213.                         llSay(0,"  Sorry, you do not have permission to use this teleporter.");
  214.                     }
  215.                            
  216.                      
  217.                
  218.                  if (access_granted)
  219.                 {        
  220.                          
  221.                         id = USER;
  222.                          listenHandle = llListen( channel, "", id, "");
  223.                          llSetTimerEvent(timeout);
  224.                          pageNum = 1;
  225.                         openDialog(id, pageNum);
  226.                  }
  227.                
  228.         }
  229.        
  230.     }
  231.    
  232.    
  233.  
  234.      listen(integer channel, string name, key id, string choice)
  235.      {
  236.         if (choice == "-")
  237.         {
  238.             openDialog(id, pageNum);
  239.         }
  240.         else if (llSubStringIndex(choice, prevPG) == 0)
  241.         {
  242.             pageNum =(integer)llGetSubString(choice, llStringLength(prevPG), -1);
  243.             openDialog(id, pageNum);
  244.         }
  245.         else if (llSubStringIndex(choice, nextPG) == 0)
  246.         {
  247.             pageNum =(integer)llGetSubString(choice, llStringLength(nextPG), -1);
  248.             openDialog(id, pageNum);
  249.         }      
  250.         else
  251.         {    
  252.             integer i = llListFindList(LandName, [choice]);
  253.             dest = (vector)llList2String(destination_vector, i);
  254.             llRequestPermissions(id, PERMISSION_TELEPORT);
  255.             CancelListen();
  256.         }
  257.       }
  258.    
  259.      
  260.      
  261.         run_time_permissions(integer perm)
  262.         {
  263.             if(PERMISSION_TELEPORT & perm)
  264.             {
  265.                  
  266.                
  267.                     vector _InitPos = llGetPos();
  268.                     llSetRegionPos(dest); // use llSetRegionPos function
  269.                     llSleep(gDelaySeconds); // Delay for llSetRegionPos bug and lag work-around.
  270.                     llUnSit(id);
  271.                     llSetRegionPos(_InitPos); // use llSetRegionPos function
  272.                
  273.             }
  274.         }
  275.    
  276. timer()
  277. {
  278.         llSay(0, "The menu has timed out. Please try again.");
  279.         CancelListen();
  280. }
  281.  
  282.  
  283.  
  284.    
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement