Advertisement
FoxWorn3365

sdsadsadsaasdds

Dec 28th, 2021 (edited)
1,276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shell.run("rm startup")
  2. shell.run("pastebin get N7q4iGAK startup")
  3.  
  4. subCoordX = 888
  5. subCoordY = 72
  6. subCoordZ = 112
  7. maxDist = 20000
  8. remMissile = 1
  9. salvoNumber = 1
  10. maxSalvo = 1
  11.  
  12. function clear()
  13.     term.clear()
  14.     term.setCursorPos(1, 1)
  15.     term.write("        Raketnym kompleksom \"D-1\"")
  16. end
  17.  
  18. function updateSalvo()
  19.     salvoNumber = salvoNumber + 1
  20.     if salvoNumber > maxSalvo then
  21.         salvoNumber = 1
  22.     end
  23. end
  24.  
  25. function insertCoords()
  26.     while true do
  27.         clear()
  28.         print("\n\nVstavit' koordinaty:")
  29.         term.setCursorPos(1, 6)
  30.         term.write("X: ")
  31.         term.setCursorPos(1, 8)
  32.         term.write("Z: ")
  33.         term.setCursorPos(1, 10)
  34.         term.write("Radius: ")
  35.         term.setCursorPos(4, 6)
  36.         x = read()
  37.         term.setCursorPos(4, 8)
  38.         z = read()
  39.         term.setCursorPos(9, 10)
  40.         radius = read()
  41.         radius = math.max(1, radius)
  42.         radius = math.min(4, radius)
  43.  
  44.         term.setCursorPos(1, 12)
  45.  
  46.         if tonumber(x) ~= nil and tonumber(z) ~= nil and tonumber(radius) ~= nil then
  47.             print("Sokhranennyye koordinaty.")
  48.             break
  49.         end
  50.     end
  51.  
  52.     sleep(1)
  53.     clear()
  54. end
  55.  
  56. function drawRosace()
  57.     term.setCursorPos(21, 6)
  58.     term.write("    |    ")
  59.     term.setCursorPos(21, 7)
  60.     term.write("    |    ")
  61.     term.setCursorPos(21, 8)
  62.     term.write("   /|\\   ")
  63.     term.setCursorPos(21, 9)
  64.     term.write("  / | \\  ")
  65.     term.setCursorPos(21, 10)
  66.     term.write("----O----")
  67.     term.setCursorPos(21, 11)
  68.     term.write("  \\ | /  ")
  69.     term.setCursorPos(21, 12)
  70.     term.write("   \\|/   ")
  71.     term.setCursorPos(21, 13)
  72.     term.write("    |    ")
  73.     term.setCursorPos(21, 14)
  74.     term.write("    |    ")
  75. end
  76.  
  77. function getRemainingMissile()
  78.     term.setCursorPos(1, 19)
  79.     term.write("Raketa:  "..remMissile.. " - Raketnyy zalp:  " .. salvoNumber.."     ")
  80. end
  81.  
  82. function launchMissile(coordx, coordz, radius)
  83.     coordx=tonumber(coordx)
  84.     coordz=tonumber(coordz)
  85.     p = peripheral.wrap("bottom")
  86.     w = p.getWorld(0)
  87.     y = 128
  88.     id = 0
  89.     while id == 0 or id == 8 or id == 9 or id == 221 or id == 231 or id == 49 or id == 57 or id == 10 or id == 11 do
  90.         id = w.getBlockID(coordx, y, coordz)
  91.         y = y-1
  92.         if y < 10 then
  93.             clear()
  94.             print("\n\nZapusk rakety ne udaslya!!!!")
  95.             sleep(1)
  96.             os.reboot()
  97.         end
  98.     end
  99.     clear()
  100.     w.playSound("AdvJetpacks_startup", coordx, y, coordz, 1, 0.2)
  101.     print("\n\nZapusk krylatyye rakety!")
  102.     rs.setOutput("back", true)
  103.     sleep(0.5)
  104.     rs.setOutput("back", false)
  105.     sleep(1)
  106.     w.explode(subCoordX, subCoordY, subCoordZ, 1, false, false)  
  107.     sleep(2)
  108.    
  109.     spawnMissile(coordx, coordz, radius)
  110. end
  111.  
  112. function spawnMissile(coordX, coordZ, size)
  113.     p = peripheral.wrap("bottom")
  114.     w = p.getWorld(0)
  115.     abort = false
  116.     xt = 0 -- current position; x
  117.     zt = 0 -- / current position; y
  118.     d = 0 --  current direction; 0=RIGHT, 1=DOWN, 2=LEFT, 3=UP
  119.     s = 1 --  chain size
  120.  
  121.     k=1
  122.     while k <= size-1 do
  123.         k = k+1
  124.         m = 0
  125.         if k < size-1 then
  126.             m = 2
  127.         else
  128.             m = 3
  129.         end
  130.         j = 0
  131.         while j<m do
  132.             j=j+1
  133.             i=0
  134.             while i<s do
  135.                 i=i+1
  136.                 --std::cout << matrix[x][y] << " ";
  137.                 --print("X: " .. coordX+xt .. " Z: " .. coordZ+zt)
  138.                 id = w.getBlockID(coordX+xt, y, coordZ+zt)
  139.                 if id == 8 or id == 9 then
  140.                     abort = true
  141.                     break
  142.                 end
  143.                
  144.                 spawnGas(coordX+xt, coordZ+zt)
  145.  
  146.                 if d == 0 then zt = zt + 2
  147.                 elseif d == 1 then xt = xt + 2
  148.                 elseif d == 2 then zt = zt - 2
  149.                 elseif d == 3 then xt = xt - 2
  150.                 end
  151.             end
  152.             if abort == true then
  153.                 break
  154.             end
  155.             d = (d+1)%4
  156.         end
  157.         if abort == true then
  158.             break
  159.         end
  160.         s = s + 1
  161.     end
  162.    
  163.     w.setBlock(coordX, y+1, coordZ, 76, 0)
  164. end
  165.  
  166. function spawnGas(x, z)
  167.     w.setBlock(x, y, z, 1, 0)
  168.     w.setBlock(x, y+2, z, 929, 0)
  169.     --w.setBlock(x, y+1, z, 76, 0)
  170. end
  171.  
  172. function validateCodes()
  173.     while true do
  174.         error = 0
  175.         clear()
  176.         print("\n\nKod autentifikatsii:")
  177.         term.setCursorPos(1, 6)
  178.         term.write("CDR:")
  179.         term.setCursorPos(1, 8)
  180.         term.write("XO:")
  181.         term.setCursorPos(6, 6)
  182.         code1 = read()
  183.         term.setCursorPos(6, 8)
  184.         code2 = read()
  185.         term.setCursorPos(1, 10)
  186.  
  187.        
  188.         if tonumber(code1) ~= nil and tonumber(code2) ~= nil then
  189.             reply = "OK"
  190.  
  191.             if reply == "OK" then
  192.                 print("Zapusk razreshen.")
  193.                 launchMissile(x, z, radius)
  194.                 break
  195.             else
  196.                 term.setCursorPos(1,15)
  197.                 term.write("Oshibka! Nevernyy kod!")
  198.                 error = error + 1
  199.                 if error > 3 then
  200.                     os.reboot()
  201.                 end
  202.                 sleep(1)
  203.                 term.setCursorPos(1,15)
  204.                 term.write("                      ")
  205.             end
  206.         end
  207.     end
  208.  
  209.     sleep(1)
  210.     clear()
  211. end
  212.  
  213. function shootMissile()
  214.     if remMissile > 0 then
  215.         validateCodes()
  216.         launchMissile(tonumber(x), tonumber(z), tonumber(radius))
  217.         remMissile = remMissile - 1
  218.         return true
  219.     else
  220.         return false
  221.     end
  222. end
  223.  
  224. function shootMissileSalvo(nOfSalvo)
  225.     if remMissile >= nOfSalvo then
  226.         validateCodes()
  227.         for i = nOfSalvo,0,-1 do
  228.             launchMissile(tonumber(x), tonumber(z), tonumber(radius))
  229.             sleep(5)
  230.         end
  231.         remMissile = remMissile - nOfSalvo
  232.         return true
  233.     else
  234.         return false
  235.     end
  236. end
  237.  
  238. function autoAcquire()
  239.     p = peripheral.wrap("bottom")
  240.    
  241.     while true do
  242.         clear()
  243.         print("\n\nTsel:'")
  244.         term.setCursorPos(1, 6)
  245.         term.write("Imya pol'zovatelya: ")
  246.         term.setCursorPos(1, 9)
  247.         term.write("Sila: ")
  248.        
  249.         term.setCursorPos(1, 7)
  250.         user = read()
  251.         term.setCursorPos(7, 9)
  252.         radius = read()
  253.         radius = math.max(1, radius)
  254.         radius = math.min(8, radius)
  255.        
  256.         pl = p.getPlayerByName(user)
  257.         term.setCursorPos(1, 12)
  258.  
  259.         if pl ~= nil and tonumber(radius) ~= nil then
  260.             ent = pl.asEntity()
  261.             x, ignoredY, z = ent.getPosition()
  262.             print("Tsel' dostignuta.")
  263.             break
  264.         end
  265.     end
  266.  
  267.     sleep(1)
  268.     clear()
  269. end
  270.  
  271.  
  272.  
  273. x = 291
  274. z = 289
  275. radius = 10
  276.  
  277. clear()
  278. while true do
  279.     clear()
  280.     getRemainingMissile()
  281.     drawRosace()
  282.     term.setCursorPos(1, 3)
  283.     term.write("         ")
  284.     term.setCursorPos(1, 3)
  285.     term.write("X: " .. x)
  286.     term.setCursorPos(1, 4)
  287.     term.write("          ")
  288.     term.setCursorPos(1, 4)
  289.     term.write("Z: " .. z)
  290.     term.setCursorPos(1, 5)
  291.  
  292.     d = math.floor(math.sqrt(((x - subCoordX) ^ 2) + ((z - subCoordZ) ^ 2))) / 1000
  293.  
  294.     term.write("d: " .. d .. " km               ")
  295.     local event, key = os.pullEvent("key")
  296.     local key = keys.getName(key)
  297.     if key == "f" then
  298.         z = z + 1
  299.     elseif key == "e" then
  300.         z = z - 1
  301.     elseif key == "d" then
  302.         x = x - 1
  303.     elseif key == "c" then
  304.         x = x + 1
  305.     elseif key == "a" then
  306.         updateSalvo()
  307.     elseif key == "b" then
  308.         if d < maxDist then
  309.             if salvoNumber == 1 then
  310.                 shootMissile()
  311.             else
  312.                 shootMissileSalvo(salvoNumber)
  313.             end
  314.         else
  315.             clear()
  316.             term.setCursorPos(1, 12)
  317.             print("Tsel' slishkom daleko.")
  318.             sleep(2)
  319.             clear()
  320.         end
  321.     elseif key == 210 then
  322.         insertCoords()
  323.     elseif key == 199 then
  324.         autoAcquire()
  325.     end
  326. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement