Advertisement
burnin_aura

[CC] [ICBM] [SILOPC] [Working]

Oct 13th, 2015
1,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 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 masterID
  11.  
  12. --[[Functions]]--
  13. local function clear()
  14.  term.clear()
  15.   term.setCursorPos(1, 1)
  16.    end
  17.  
  18. rednet.open("top")
  19. --[[Main program]]--
  20. clear()
  21. while true do
  22.   print("Waiting for Launch Confirmation Message")
  23.   id, msg, distance = rednet.receive(masterID)
  24.  
  25.   if (msg == "ping silo") then
  26.     print("  master=", id)
  27.     masterID = id;
  28.     rednet.send(masterID, "pong")
  29.   elseif type(msg) == "table" and id == masterID then
  30.     if type(msg.x) == "number" and type(msg.y) == "number" and type(msg.z) == "number" then
  31.       print("  launch to x=" .. msg.x .. ", y=" .. msg.y .. ", z=" .. msg.z)
  32.       icbm.setTarget(msg.x, msg.y, msg.z)
  33.       if (armed) then
  34.         peripheral.call("back","launch")
  35.       end
  36.     else
  37.       print("  invalid table command")
  38.     end
  39.   else
  40.     print("  invalid msg '", msg, "' from '", id, "', distance=", distance)
  41.   end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement