Jakey4543

PhoneApp

Dec 24th, 2020 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. --// Phone app
  2.  
  3. local SERVER_PORT = 3230
  4. local PHONE_PORT = 2212
  5.  
  6. modem = peripheral.wrap("back")
  7. modem.open(PHONE_PORT)
  8. local size = nil
  9. local axis = 0
  10. local len = 0
  11.  
  12. if (#arg == 3) then
  13.     size = arg[1]
  14.     axis = arg[2]
  15.     len  = arg[3]
  16. else
  17.     error("VALUE MISSING")
  18.     return
  19. end
  20.  
  21. local target = vector.new(gps.locate())
  22. local payloadMessage = string.format("%d %d %d %d %d",
  23.     target.x-1, target.y-1, target.z,
  24.     size,
  25.     axis,
  26.     len
  27. )
  28.  
  29. print(string.format("Targetting %d %d %d", target.x, target.y, target.z))
  30. modem.transmit(SERVER_PORT,PHONE_PORT,payloadMessage)
  31. print("Waiting for return signal...")
  32. event, side, senderChannel, replyChannel, msg, distance = os.pullEvent("modem_message")
  33. print("RETURN MESSAGE: "..msg)
Add Comment
Please, Sign In to add comment