Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[Skynet Nuclear Defense Program by Andrew2060]--
- --[To be used with http://pastebin.com/exm7HRhr]--
- --[[Settings]]--
- local modemSide = "top"
- local waitDelay = 2
- --[[Init]]--
- rednet.open(modemSide)
- local silos = {}
- --[[Functions]]--
- local function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- term.setBackgroundColor(colors.blue)
- paintutils.drawLine(2, 10, 45, 10, colors.red)
- clear()
- local function findSilos()
- rednet.broadcast("ping silo")
- local timerID = os.startTimer(waitDelay)
- while true do
- event, id, msg, distance = os.pullEvent()
- if event == "rednet_message" and msg == "pong" then
- table.insert(silos, id)
- timerID = os.startTimer(waitDelay)
- elseif event == "timer" and id == timerID then
- return
- end
- end
- end
- local function launch(count, x, y, z)
- local msg = {x = x, y = y, z = z}
- local count = math.max(count, #silos)
- print("launching " .. count .. " rocket(s) at " .. x .. ", " .. y .. ", " .. z)
- for i = 1, count do
- rednet.send(silos[i], msg)
- end
- sleep(3)
- end
- local function printSilos()
- clear()
- print("===============================")
- print(" [Detected silos] ")
- for k, v in ipairs(silos) do
- print(" silo #" .. k .. " id = "..v)
- end
- print("===============================")
- term.setBackgroundColor(colors.red)
- print(" ")
- print(" ")
- term.setBackgroundColor(colors.blue)
- end
- --[[Main program]]--
- findSilos()
- while true do
- printSilos()
- print("===============================")
- print(" [Launch Confirmation] ")
- print("===============================")
- paintutils.drawLine(2, 10, 45, 10, colors.red)
- textutils.slowPrint("Enter Confirmation Code:")
- input = read("*")
- term.setBackgroundColor(colors.red)
- print(" ")
- print(" ")
- term.setBackgroundColor(colors.blue)
- if input == "exit" then
- break
- elseif input == "949-854-3444" then --Add preferred password within quotes
- local count, x, y, z
- while not (type(count) == "number" and type(x) == "number" and type(y) == "number" and type(z) == "number") do
- print("===============================")
- print(" [Target Selection] ")
- print("===============================")
- paintutils.drawLine(2, 10, 45, 10, colors.red)
- write("Warhead count: ")
- count = tonumber(read())
- print("Coordinates:")
- write("X: ")
- x = tonumber(read())
- write("Y: ")
- y = tonumber(read())
- write("Z: ")
- z = tonumber(read())
- end
- launch(count, x, y, z)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement