Advertisement
natie3

moveApi

Nov 20th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. function getRoute(x1,y1,z1,x2,y2,z2,dir)
  2.   id = 1234
  3.   request = textutils.serialize({ beginx = x1, eindx = x2, beginy = y1, eindy = y2, beginz = z1, eindz = z2, facing =  dir })
  4.   tabel = { type = "routeRequest", id = id, request = request }
  5.   table.insert(tabel,request)
  6.   modem.transmit(7000,7001,textutils.serialize(tabel))
  7.   modem.open(7001)
  8.   correct = false
  9.   route = nil
  10.   while not correct do
  11.     event = { os.pullEvent("modem_message") }
  12.     data = textutils.unserialize(event[5])
  13.     if data.type == "routeAnswer" and data.id == id then
  14.       route = data.route
  15.       correct = true
  16.     end
  17.   end
  18.   return route
  19. end
  20.  
  21. function reportObstacle(x,y,z)
  22.   info = { x = x, y = y, z = z }
  23.   tabel = { type = "addObstacle", info = info }
  24.   modem.transmit(7000,7001,textutils.serialize(tabel))
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement