Advertisement
Aidan428

ICBM Launch Slave

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