Advertisement
thatparadox

ICBMlauncher

Dec 23rd, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. for k,v in pairs(rs.getSides()) do
  2.   if peripheral.getType(v ) == "modem" then
  3.    rednet.open(v)
  4.    break
  5.   end
  6. end
  7. for k,v in pairs(rs.getSides()) do
  8.   if peripheral.getType(v) == "ICBMLauncher" then
  9.    icbm = peripheral.wrap(v)
  10.    break
  11.   end
  12. end
  13.  
  14. if fs.exists("panel") then
  15.   file = fs.open("panel", "r")
  16.     panel = tonumber(file.readAll())
  17.   file.close()
  18. else
  19.   term.clear()
  20.   term.setCursorPos(1,1)
  21.   write("Enter ID of TouchScreen Computer: ")
  22.   panel = read()
  23.   term.clear()
  24.   file = fs.open("panel", "w")
  25.   file.write(panel)
  26.   panel = tonumber(panel)
  27.   file.close()
  28. end
  29.  
  30. while true do
  31.   x,y,z = icbm.getTarget()
  32.   rednet.send(panel, x)
  33.   test = rednet.receive(1)
  34.   if test ~= nil then
  35.     rednet.send(panel, y)
  36.     rednet.receive()
  37.     rednet.send(panel, z)
  38.     rednet.receive()
  39.     id, message = rednet.receive()
  40.     if id == panel and message == "coords" then
  41.       print("Coords updated")
  42.       rednet.send(panel, "ready")
  43.       id, x = rednet.receive()
  44.       rednet.send(panel, "ready")
  45.       id, y = rednet.receive()
  46.       rednet.send(panel, "ready")
  47.       id, z = rednet.receive()
  48.       x = tonumber(x)
  49.       y = tonumber(y)
  50.       z = tonumber(z)
  51.       icbm.setTarget(x,y,z)
  52.     elseif id == panel and message == "launch" then
  53.       icbm.launch()
  54.     end
  55.   end
  56.   os.sleep(.5)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement