Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.write(" Raketnym kompleksom \"D-4\"")
- 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(4, 6)
- x = read()
- term.setCursorPos(4, 8)
- z = read()
- term.setCursorPos(1, 10)
- if tonumber(x) ~= nil and tonumber(z) ~= 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)
- if remMissile == 3 then
- term.write("Raketa: [1] [2] [3] ")
- elseif remMissile == 2 then
- term.write("Raketa: [ ] [2] [3] ")
- elseif remMissile == 1 then
- term.write("Raketa: [ ] [ ] [3] ")
- elseif remMissile == 0 then
- term.write("Raketa: [ ] [ ] [ ] ")
- end
- end
- function launchMissile(coordx, coordz)
- p = peripheral.wrap("bottom")
- w = p.getWorld(0)
- y = 128
- id = 0
- while id == 0 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 ballisticheskoy rakety!")
- rs.setOutput("back", true)
- sleep(0.5)
- rs.setOutput("back", false)
- sleep(1)
- w.explode(-1869, 73, -1963, 1, false, false)
- sleep(2)
- w.setBlock(coordx, y, coordz, 1, 0)
- w.setBlock(coordx, y+2, coordz, 929, 0)
- w.setBlock(coordx+3, y+2, coordz, 929, 0)
- w.setBlock(coordx+6, y+2, coordz, 929, 0)
- w.setBlock(coordx-3, y+2, coordz, 929, 0)
- w.setBlock(coordx-6, y+2, coordz, 929, 0)
- w.setBlock(coordx, y+1, coordz, 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
- rest = http.get("http://172.16.20.220/luanet/servlets/ssb/k129.php?code1="..code1.."&code2="..code2)
- reply = rest.readAll()
- rest.close()
- if reply == "OK" then
- print("Zapusk razreshen.")
- launchMissile(x, z)
- 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(x, z)
- remMissile = remMissile - 1
- return true
- else
- return false
- end
- end
- remMissile = 3
- x = 75
- z = 900
- xo = -1881
- zo = -1966
- clear()
- while true do
- 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 - xo) ^ 2) + ((z - zo) ^ 2))) / 1000
- term.write("d: " .. d .. " km ")
- local event, key = os.pullEvent("key")
- if key == 200 then
- z = z + 1
- elseif key == 208 then
- z = z - 1
- elseif key == 203 then
- x = x - 1
- elseif key == 205 then
- x = x + 1
- elseif key == 57 then
- shootMissile()
- elseif key == 210 then
- insertCoords()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement