Advertisement
Guest User

facing

a guest
Jul 25th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. local x, y, z = gps.locate(5)
  2.  
  3. function getLoc()
  4.   x, y, z = gps.locate(5)
  5. end
  6. function getDirec()
  7.   getLoc()
  8.   local xHold = x
  9.   local yHold = y
  10.   local zHold = z
  11.  
  12.   turtle.forward()
  13.   getLoc()
  14.  
  15.   if x > xHold then
  16.     rednet.send(1, "I am facing east.")
  17.     return("east")
  18.   elseif x < xHold then
  19.     rednet.send(1, "I am facing west.")
  20.     return("west")
  21.   elseif z > zHold then
  22.     rednet.send(1, "I am facing south.")
  23.     return("south")
  24.   elseif z < zHold then
  25.     rednet.send(1, "I am facing north.")
  26.   return("north")
  27.   end
  28.  
  29.   turtle.back()
  30. end
  31.  
  32. getDirec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement