Advertisement
Maxstripe

Untitled

Oct 23rd, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[Skynet Nuclear Defense Program by Andrew2060]--
  2. --[To be used with http://pastebin.com/exm7HRhr]--
  3.  
  4. --[[Settings]]--
  5. local modemSide = "top"
  6. local waitDelay = 2
  7.  
  8. --[[Init]]--
  9. rednet.open(modemSide)
  10. local silos = {}
  11.  
  12. --[[Functions]]--
  13. local function clear()
  14.   term.clear()
  15.   term.setCursorPos(1, 1)
  16. end
  17.  
  18. term.setBackgroundColor(colors.blue)
  19. paintutils.drawLine(2, 10, 45, 10, colors.red)
  20. clear()
  21.  
  22. local function findSilos()
  23.     rednet.broadcast("ping silo")
  24.  
  25.   local timerID = os.startTimer(waitDelay)
  26.  
  27.   while true do
  28.     event, id, msg, distance = os.pullEvent()
  29.    
  30.     if event == "rednet_message" and msg == "pong" then
  31.       table.insert(silos, id)
  32.       timerID = os.startTimer(waitDelay)
  33.     elseif event == "timer" and id == timerID then
  34.        return
  35.     end
  36.   end
  37. end
  38.  
  39. local function launch(count, x, y, z)
  40.   local msg = {x = x, y = y, z = z}
  41.   local count = math.max(count, #silos)
  42.   print("launching " .. count .. " rocket(s) at " .. x .. ", " .. y .. ", " .. z)
  43.   for i = 1, count do
  44.     rednet.send(silos[i], msg)
  45.   end
  46.   sleep(3)
  47. end
  48.  
  49. local function printSilos()
  50.   clear()
  51.     print("===============================")
  52.     print("        [Detected silos]       ")
  53.     for k, v in ipairs(silos) do
  54.     print("  silo #" .. k .. " id = "..v)
  55.   end
  56.     print("===============================")
  57.     term.setBackgroundColor(colors.red)
  58.     print("                               ")
  59.     print("                               ")
  60.     term.setBackgroundColor(colors.blue)
  61. end
  62.  
  63. --[[Main program]]--
  64. findSilos()
  65.  
  66. while true do
  67.   printSilos()
  68.   print("===============================")
  69.   print("     [Launch Confirmation]     ")
  70.   print("===============================")
  71.   paintutils.drawLine(2, 10, 45, 10, colors.red)
  72.   textutils.slowPrint("Enter Confirmation Code:")
  73.   input  = read("*")
  74.   term.setBackgroundColor(colors.red)
  75.   print("                               ")
  76.   print("                               ")
  77.   term.setBackgroundColor(colors.blue)
  78.   if input == "exit" then
  79.     break
  80.   elseif input == "949-854-3444" then  --Add preferred password within quotes
  81.     local count, x, y, z
  82.     while not (type(count) == "number" and type(x) == "number" and type(y) == "number" and type(z) == "number") do
  83.       print("===============================")
  84.       print("      [Target Selection]       ")
  85.       print("===============================")
  86.       paintutils.drawLine(2, 10, 45, 10, colors.red)
  87.       write("Warhead count: ")
  88.       count = tonumber(read())
  89.       print("Coordinates:")
  90.       write("X: ")
  91.       x = tonumber(read())
  92.       write("Y: ")
  93.       y = tonumber(read())
  94.       write("Z: ")
  95.       z = tonumber(read())
  96.     end
  97.     launch(count, x, y, z)
  98.     os.reboot()
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement