Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- current_x = 0
- current_y = 0
- function move_back_to ( y )
- turtle.turnLeft()
- turtle.turnLeft()
- while current_y > y do
- turtle.dig()
- res = turtle.forward()
- if res then
- current_y = current_y - 1
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function move_forward_to ( y )
- while current_y < y do
- turtle.dig()
- res = turtle.forward()
- if res then
- current_y = current_y + 1
- end
- end
- end
- function move_left_to ( x )
- turtle.turnLeft()
- while current_x > x do
- turtle.dig()
- res = turtle.forward()
- if res then
- current_x = current_x - 1
- end
- end
- turtle.turnRight()
- end
- function move_right_to ( x )
- turtle.turnRight()
- while current_x < x do
- turtle.dig()
- res = turtle.forward()
- if res then
- current_x = current_x + 1
- end
- end
- turtle.turnLeft()
- end
- function move_to ( x , y )
- if x > current_x then
- move_right_to(x)
- end
- if x < current_x then
- move_left_to(x)
- end
- if y > current_y then
- move_forward_to(y)
- end
- if y < current_y then
- move_back_to(y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement