Advertisement
burnin_aura

[CC] [ICBM] [ABM Server] [WORKING]

Jul 11th, 2015
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. --[[Skynet Nuclear ABM Defense Program by Andrew2060]]--
  2. --[ABM Server, use with http://pastebin.com/aNsduCem]]--
  3. --[System requires atleast 5 CC's with Modems and ABMs]]--
  4. --[System has 5% chance of failure in killing missiles]]--
  5.  
  6. --[[Settings]]--
  7. local waitDelay = 2
  8. local countersPerMissile = 1
  9. local missileDelay = 3
  10.  
  11. --[[Initialization]]--
  12. local silos, curSilo = {}, 1
  13. peripheral.find("modem", rednet.open)
  14. term.setBackgroundColor(colors.blue)
  15.  
  16. local function red()
  17. term.setBackgroundColor(colors.red)
  18. print("                                                   ")
  19. term.setBackgroundColor(colors.blue)
  20. end
  21.  
  22. rednet.broadcast("ABM1")
  23.  
  24. repeat
  25.     local id, msg = rednet.receive(waitDelay)
  26.     if msg == "ABM" then table.insert(silos, id) end
  27. until not id
  28.  
  29. --[[Main Programs]]--
  30. while true do
  31.     if not redstone.getInput("back") then
  32.         term.clear()
  33.         term.setCursorPos(1, 1)
  34.  
  35.         red()
  36.         print("        SKYNET DEFENSE SYSTEMS ACTIVATED           ")
  37.         red()
  38.         print("      ANTI-BALLISTIC MISSILE SHIELD ONLINE         ")
  39.         red()
  40.         red()
  41.         print("               [STANDBY ABM Silos]                 ")
  42.  
  43.         for k, v in ipairs(silos) do print("  silo #" .. k .. " id = "..v) end
  44.         red()
  45.        
  46.         repeat os.pullEvent("redstone") until redstone.getInput("back")
  47.     end
  48.    
  49.     term.clear()
  50.     term.setCursorPos(1, 1)
  51.     term.setTextColor(colors.red)
  52.    
  53.     print("Incoming Missiles:")
  54.     print("Firing CounterMeasures\n")
  55.    
  56.  maptab = peripheral.call("back","getEntities")
  57.  maptxt = textutils.serialize(maptab)
  58.  if maptxt ~= "{}" then
  59.  allDat = 0
  60.  for num in pairs(maptab) do
  61.  allDat = allDat+1
  62.  end
  63.  targets = allDat/3
  64.  for i=0,targets-1 do
  65.         local msg = {["x"] = math.floor(maptab["x_"..i]), ["y"] = math.floor(maptab["y_"..i]), ["z"] = math.floor(maptab["z_"..i])}
  66.  
  67.         print("Incoming Missile Threat #" .. i .. " at X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z)
  68.         print("Launching " .. countersPerMissile .. " of ABM Missile CounterMeasures...\n")
  69.  
  70.         for i = 1, countersPerMissile do
  71.             rednet.send(silos[curSilo], msg)
  72.             curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
  73.             sleep(missileDelay)
  74.             end
  75.         sleep(0)
  76.         end
  77.      sleep(0)
  78.     end
  79.    sleep(2)
  80. end
  81. sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement