Advertisement
Guest User

Untitled

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