Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- location = vector.new(gps.locate())
- start = location
- target = vector.new(5,0,8)
- face = 3
- function direction(x)
- while face ~= x do
- turtle.turnRight()
- face = face + 1
- if face == 5 then face = 1 end
- end
- end
- function navigation()
- location = vector.new(gps.locate())
- move = target - location
- print(move)
- if move.x < 0 then
- direction(4)
- elseif move.x > 0 then
- direction(2)
- elseif move.x == 0 then
- direction(1)
- end
- for i = 1, math.abs(move.x) do
- turtle.forward()
- end
- if move.z < 0 then
- direction(1)
- else
- direction(3)
- end
- for i = 1, math.abs(move.z) do
- turtle.forward()
- end
- end
- navigation()
- target = start
- navigation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement