Advertisement
Aidan428

ABM Client 1

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