Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("rm startup")
- shell.run("pastebin get N7q4iGAK startup")
- subCoordX = 888
- subCoordY = 72
- subCoordZ = 112
- maxDist = 20000
- remMissile = 1
- salvoNumber = 1
- maxSalvo = 1
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.write(" Raketnym kompleksom \"D-1\"")
- end
- function updateSalvo()
- salvoNumber = salvoNumber + 1
- if salvoNumber > maxSalvo then
- salvoNumber = 1
- end
- end
- function insertCoords()
- while true do
- clear()
- print("\n\nVstavit' koordinaty:")
- term.setCursorPos(1, 6)
- term.write("X: ")
- term.setCursorPos(1, 8)
- term.write("Z: ")
- term.setCursorPos(1, 10)
- term.write("Radius: ")
- term.setCursorPos(4, 6)
- x = read()
- term.setCursorPos(4, 8)
- z = read()
- term.setCursorPos(9, 10)
- radius = read()
- radius = math.max(1, radius)
- radius = math.min(4, radius)
- term.setCursorPos(1, 12)
- if tonumber(x) ~= nil and tonumber(z) ~= nil and tonumber(radius) ~= nil then
- print("Sokhranennyye koordinaty.")
- break
- end
- end
- sleep(1)
- clear()
- end
- function drawRosace()
- term.setCursorPos(21, 6)
- term.write(" | ")
- term.setCursorPos(21, 7)
- term.write(" | ")
- term.setCursorPos(21, 8)
- term.write(" /|\\ ")
- term.setCursorPos(21, 9)
- term.write(" / | \\ ")
- term.setCursorPos(21, 10)
- term.write("----O----")
- term.setCursorPos(21, 11)
- term.write(" \\ | / ")
- term.setCursorPos(21, 12)
- term.write(" \\|/ ")
- term.setCursorPos(21, 13)
- term.write(" | ")
- term.setCursorPos(21, 14)
- term.write(" | ")
- end
- function getRemainingMissile()
- term.setCursorPos(1, 19)
- term.write("Raketa: "..remMissile.. " - Raketnyy zalp: " .. salvoNumber.." ")
- end
- function launchMissile(coordx, coordz, radius)
- coordx=tonumber(coordx)
- coordz=tonumber(coordz)
- p = peripheral.wrap("bottom")
- w = p.getWorld(0)
- y = 128
- id = 0
- 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
- id = w.getBlockID(coordx, y, coordz)
- y = y-1
- if y < 10 then
- clear()
- print("\n\nZapusk rakety ne udaslya!!!!")
- sleep(1)
- os.reboot()
- end
- end
- clear()
- w.playSound("AdvJetpacks_startup", coordx, y, coordz, 1, 0.2)
- print("\n\nZapusk krylatyye rakety!")
- rs.setOutput("back", true)
- sleep(0.5)
- rs.setOutput("back", false)
- sleep(1)
- w.explode(subCoordX, subCoordY, subCoordZ, 1, false, false)
- sleep(2)
- spawnMissile(coordx, coordz, radius)
- end
- function spawnMissile(coordX, coordZ, size)
- p = peripheral.wrap("bottom")
- w = p.getWorld(0)
- abort = false
- xt = 0 -- current position; x
- zt = 0 -- / current position; y
- d = 0 -- current direction; 0=RIGHT, 1=DOWN, 2=LEFT, 3=UP
- s = 1 -- chain size
- k=1
- while k <= size-1 do
- k = k+1
- m = 0
- if k < size-1 then
- m = 2
- else
- m = 3
- end
- j = 0
- while j<m do
- j=j+1
- i=0
- while i<s do
- i=i+1
- --std::cout << matrix[x][y] << " ";
- --print("X: " .. coordX+xt .. " Z: " .. coordZ+zt)
- id = w.getBlockID(coordX+xt, y, coordZ+zt)
- if id == 8 or id == 9 then
- abort = true
- break
- end
- spawnGas(coordX+xt, coordZ+zt)
- if d == 0 then zt = zt + 2
- elseif d == 1 then xt = xt + 2
- elseif d == 2 then zt = zt - 2
- elseif d == 3 then xt = xt - 2
- end
- end
- if abort == true then
- break
- end
- d = (d+1)%4
- end
- if abort == true then
- break
- end
- s = s + 1
- end
- w.setBlock(coordX, y+1, coordZ, 76, 0)
- end
- function spawnGas(x, z)
- w.setBlock(x, y, z, 1, 0)
- w.setBlock(x, y+2, z, 929, 0)
- --w.setBlock(x, y+1, z, 76, 0)
- end
- function validateCodes()
- while true do
- error = 0
- clear()
- print("\n\nKod autentifikatsii:")
- term.setCursorPos(1, 6)
- term.write("CDR:")
- term.setCursorPos(1, 8)
- term.write("XO:")
- term.setCursorPos(6, 6)
- code1 = read()
- term.setCursorPos(6, 8)
- code2 = read()
- term.setCursorPos(1, 10)
- if tonumber(code1) ~= nil and tonumber(code2) ~= nil then
- reply = "OK"
- if reply == "OK" then
- print("Zapusk razreshen.")
- launchMissile(x, z, radius)
- break
- else
- term.setCursorPos(1,15)
- term.write("Oshibka! Nevernyy kod!")
- error = error + 1
- if error > 3 then
- os.reboot()
- end
- sleep(1)
- term.setCursorPos(1,15)
- term.write(" ")
- end
- end
- end
- sleep(1)
- clear()
- end
- function shootMissile()
- if remMissile > 0 then
- validateCodes()
- launchMissile(tonumber(x), tonumber(z), tonumber(radius))
- remMissile = remMissile - 1
- return true
- else
- return false
- end
- end
- function shootMissileSalvo(nOfSalvo)
- if remMissile >= nOfSalvo then
- validateCodes()
- for i = nOfSalvo,0,-1 do
- launchMissile(tonumber(x), tonumber(z), tonumber(radius))
- sleep(5)
- end
- remMissile = remMissile - nOfSalvo
- return true
- else
- return false
- end
- end
- function autoAcquire()
- p = peripheral.wrap("bottom")
- while true do
- clear()
- print("\n\nTsel:'")
- term.setCursorPos(1, 6)
- term.write("Imya pol'zovatelya: ")
- term.setCursorPos(1, 9)
- term.write("Sila: ")
- term.setCursorPos(1, 7)
- user = read()
- term.setCursorPos(7, 9)
- radius = read()
- radius = math.max(1, radius)
- radius = math.min(8, radius)
- pl = p.getPlayerByName(user)
- term.setCursorPos(1, 12)
- if pl ~= nil and tonumber(radius) ~= nil then
- ent = pl.asEntity()
- x, ignoredY, z = ent.getPosition()
- print("Tsel' dostignuta.")
- break
- end
- end
- sleep(1)
- clear()
- end
- x = 291
- z = 289
- radius = 10
- clear()
- while true do
- clear()
- getRemainingMissile()
- drawRosace()
- term.setCursorPos(1, 3)
- term.write(" ")
- term.setCursorPos(1, 3)
- term.write("X: " .. x)
- term.setCursorPos(1, 4)
- term.write(" ")
- term.setCursorPos(1, 4)
- term.write("Z: " .. z)
- term.setCursorPos(1, 5)
- d = math.floor(math.sqrt(((x - subCoordX) ^ 2) + ((z - subCoordZ) ^ 2))) / 1000
- term.write("d: " .. d .. " km ")
- local event, key = os.pullEvent("key")
- local key = keys.getName(key)
- if key == "f" then
- z = z + 1
- elseif key == "e" then
- z = z - 1
- elseif key == "d" then
- x = x - 1
- elseif key == "c" then
- x = x + 1
- elseif key == "a" then
- updateSalvo()
- elseif key == "b" then
- if d < maxDist then
- if salvoNumber == 1 then
- shootMissile()
- else
- shootMissileSalvo(salvoNumber)
- end
- else
- clear()
- term.setCursorPos(1, 12)
- print("Tsel' slishkom daleko.")
- sleep(2)
- clear()
- end
- elseif key == 210 then
- insertCoords()
- elseif key == 199 then
- autoAcquire()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement