Advertisement
Guest User

test2

a guest
Apr 23rd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. location = vector.new(gps.locate())
  2. start = location
  3. target = vector.new(5,0,8)
  4. face = 3
  5.  
  6. function direction(x)
  7.     while face ~= x do
  8.             turtle.turnRight()
  9.             face = face + 1
  10.             if face == 5 then face = 1 end
  11.     end
  12. end
  13.  
  14. function navigation()
  15.     location = vector.new(gps.locate())
  16.     move = target - location
  17.     print(move)
  18.     if move.x < 0 then
  19.             direction(4)
  20.     elseif move.x > 0 then
  21.         direction(2)
  22.     elseif move.x == 0 then
  23.         direction(1)
  24.     end
  25.      
  26.     for i = 1, math.abs(move.x) do
  27.         turtle.forward()
  28.     end
  29.  
  30.  
  31.     if move.z < 0 then
  32.         direction(1)
  33.        
  34.     else
  35.         direction(3)
  36.     end
  37.  
  38.     for i = 1, math.abs(move.z) do
  39.         turtle.forward()
  40.     end
  41. end
  42. navigation()
  43.  
  44. target = start
  45. navigation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement