burnin_aura

ABM Client WIP v3

Mar 21st, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --Silo Launch PC, [working] [By Andrew2060]
  2.  
  3. --[[Settings]]--
  4. local icbmSide = "back"
  5. local armed = true
  6. --set armed to false to disarm silo.
  7.  
  8. --[[Init]]--
  9. local icbm = peripheral.wrap(icbmSide)
  10. local missile = peripheral.call("back", "getMissile")
  11. local confirmation == "ABM"
  12. local masterID
  13. local data = {}
  14.  
  15. peripheral.find("modem", rednet.open)
  16.  
  17. --[[Functions]]--
  18. local function clear()
  19. term.clear()
  20. term.setCursorPos(1, 1)
  21. end
  22.  
  23.  
  24. --[[Main program]]--
  25. clear()
  26. while true do
  27.   print("Waiting for Threat Message")
  28.   id, msg, distance = rednet.receive(masterID)
  29.  
  30.   if (msg == "ABM1") then
  31.     print("  master=", id)
  32.     masterID = id;
  33. table.insert(data, masterID)
  34. table.insert(data, 2, confirmation)
  35. table.insert(data, 3, missile)
  36.     rednet.send(masterID, data)
  37.   elseif type(msg) == "table" and id == masterID then
  38.     if type(msg.x) == "number" and type(msg.y) == "number" and type(msg.z) == "number" then
  39.       print("  launching CounterMeasures At x=" .. msg.x .. ", y=" .. msg.y .. ", z=" .. msg.z)
  40.       icbm.setTarget(msg.x, msg.y, msg.z)
  41.       if (armed) then
  42.         peripheral.call("back","launch")
  43.       end
  44.     else
  45.       print("  invalid table command")
  46.     end
  47.   else
  48.     print("  invalid msg '", msg, "' from '", id, "', distance=", distance)
  49.   end
  50. end
Add Comment
Please, Sign In to add comment