Advertisement
PerryExtra

StargateDialing

Apr 23rd, 2024 (edited)
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.04 KB | Gaming | 0 0
  1. ADDRESSES = {
  2.     {"Abydos", {26, 6, 14, 31, 11, 29, 0}},
  3.     {"Chulak", {8, 1, 22, 14, 36, 19, 0}},
  4.     {"Cavum Tenebrae", {18, 7, 3, 36, 25, 15, 0}},
  5.     {"Lantea", {18, 20, 1, 15, 14, 7, 19, 0}},
  6.     {"Overworld", {27, 25, 4, 35, 10, 28, 0}},
  7.     {"Nether", {27, 23, 4, 34, 12, 28, 0}},
  8.     {"End", {13, 24, 2, 19, 3, 30, 0}},
  9.     {"Aether", {8, 7, 2, 17, 6, 21, 0}},
  10.     {"Twilight Forest", {36, 33, 16, 25, 7, 14, 0}},
  11.     {"Lost City", {13, 4, 27, 8, 19, 3, 0}},
  12.     {"Glacio", {26, 20, 4, 36, 9, 27, 0}},
  13.     {"ATM Mining", {25, 33, 20, 7, 37, 17, 0}},
  14.     {"ATM Other", {12, 23, 36, 13, 21, 16, 0}},
  15.     {"ATM Beyond", {27, 5, 2, 23, 17, 38, 0}},
  16.     {"Alfeim", {4, 9, 13, 11, 20, 7, 0}},
  17.     {"Everbright", {24, 23, 37, 26, 35, 12, 0}},
  18.     {"Everdawn", {5, 7, 10, 16, 26, 21, 0}},
  19.     {"Otherside", {4, 13, 27, 12, 24, 17, 0}},
  20.     {"Undergarden", {2, 4, 6, 31, 21, 35, 0}},
  21.     {"Voidscape", {26, 5, 4, 11, 2, 37, 0}}
  22. };
  23. INTERFACE_TYPES = {
  24.     "basic_Interface",
  25.     "crystal_Interface",
  26.     "advanced_crystal_Interface"
  27. };
  28. STARGATE_TYPES = {
  29.     "sgjourney:classic_stargate",
  30.     "sgjourney:milky_way_stargate",
  31.     "sgjourney:pegasus_stargate",
  32.     "sgjourney:universe_stargate",
  33.     "sgjourney:tollan_stargate"
  34. };
  35.  
  36. function ClearScreen()
  37.     term.clear();
  38.     term.setCursorPos(1, 1);
  39. end
  40. ClearScreen();
  41.  
  42. --Function argument calls--
  43. local arg = {...};
  44. IsFastDial = false;
  45. for _,v in pairs(arg) do
  46.     if v == "--fast" then
  47.         IsFastDial = true;
  48.     elseif v then
  49.         error("Bad flag [" .. v .. "] failed to initialise", 0);
  50.     end
  51. end
  52.  
  53. --Find the proper Interface--
  54. InterfaceType = INTERFACE_TYPES[1];
  55. Interface = peripheral.find(InterfaceType);
  56. if Interface == nil then
  57.     print("\"" .. INTERFACE_TYPES[1] .. "\" was not found attempting to find another");
  58.     InterfaceType = INTERFACE_TYPES[2];
  59.     Interface = peripheral.find(InterfaceType);
  60. elseif Interface == nil then
  61.     print("\"" .. INTERFACE_TYPES[2] .. "\" was not found attempting to find another");
  62.     InterfaceType = INTERFACE_TYPES[3];
  63.     Interface = peripheral.find(InterfaceType);
  64. elseif Interface == nil then
  65.     print("\"" .. INTERFACE_TYPES[3] .. "\" was not found attempting to find another");
  66.     error("No Interfaces were found", 0);
  67. end
  68.  
  69. print("\"" .. InterfaceType .. "\" was found");
  70. StargateType = Interface.getStargateType();
  71.  
  72. print("Interface Type : " .. InterfaceType);
  73. print("Stargate Type : " .. StargateType);
  74. print("\"");
  75.  
  76. --Check if selected stargate and flags can be used by current Interface--
  77. if (IsFastDial == true or StargateType ~= STARGATE_TYPES[2]) and InterfaceType == INTERFACE_TYPES[1] then
  78.     error("\"" .. INTERFACE_TYPES[1] .. "\" can only be used with \"" .. STARGATE_TYPES[2] "\" in default manual dial mode", 0);
  79. end
  80.  
  81. --Close Stargate and/or Reset Cheverons--
  82. function Reset()
  83.     Interface.disconnectStargate();
  84.     if Interface.isStargateConnected() then
  85.         os.sleep(2.75);
  86.     end
  87. end
  88.  
  89. --Call an address and try to make a connection--
  90. function Dial(address)
  91.     Reset();
  92.     local addressLength = #address;
  93.    
  94.     if StargateType ~= STARGATE_TYPES[4] then
  95.         if addressLength == 8 then
  96.             Interface.setChevronConfiguration({0, 1, 2, 3, 4, 6, 7, 8, 5});
  97.         elseif addressLength == 9 then
  98.             Interface.setChevronConfiguration({0, 1, 2, 3, 4, 5, 6, 7, 8});
  99.         end
  100.     end
  101.    
  102.     local start = Interface.getChevronsEngaged() + 1;
  103.    
  104.     if StargateType == STARGATE_TYPES[2] and IsFastDial == false then
  105.         for chevron = start,addressLength,1
  106.         do
  107.             local symbol = address[chevron];
  108.        
  109.             if chevron % 2 == 0 then
  110.                 Interface.rotateClockwise(symbol);
  111.             else
  112.                 Interface.rotateAntiClockwise(symbol);
  113.             end
  114.        
  115.             while(not Interface.isCurrentSymbol(symbol))
  116.             do
  117.                 os.sleep(0);
  118.             end
  119.        
  120.             Interface.endRotation();
  121.        
  122.             os.sleep(1);
  123.             Interface.openChevron();
  124.                
  125.             os.sleep(0.5)
  126.             if chevron < addressLength then
  127.                 Interface.encodeChevron();
  128.             end
  129.        
  130.             os.sleep(0.5);
  131.             Interface.closeChevron();
  132.             sleep(1);
  133.         end
  134.     else
  135.         for chevron = start,addressLength,1
  136.         do
  137.             local symbol = address[chevron];
  138.             Interface.engageSymbol(symbol);
  139.             os.sleep(0.25);
  140.         end
  141.     end
  142. end
  143.  
  144. --Player Input--
  145. print("Avaiting input:");
  146. for k,v in ipairs(ADDRESSES) do
  147.     print(k .. " : " .. v[1]);
  148. end
  149.  
  150. input = tonumber(io.read());
  151. os.sleep(0);
  152.  
  153. local addressLength = #ADDRESSES;
  154. if input < 1 or input > addressLength then
  155.     error("Entered value is incorrect", 0);
  156. end
  157. if #ADDRESSES[input][2] > 7 and InterfaceType == INTERFACE_TYPES[1] then
  158.     error("Cannot dial 8 or 9 chevron address with \"" .. INTERFACE_TYPES[1] .. "\" please upgrade to \"" .. INTERFACE_TYPES[2] .. "\" or \"" .. INTERFACE_TYPES[3] .. "\"");
  159. end
  160.  
  161. Dial(ADDRESSES[input][2]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement