Advertisement
Guest User

adsfa

a guest
May 26th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. --moving the computer in a strafe like fashion (as opposed to 'normal' movement)
  2. function strafe(direction)
  3.  
  4. if direction == "right" then
  5. turtle.turnRight()
  6. turtle.forward()
  7. turtle.turnLeft()
  8. elseif direction == "left" then
  9. turtle.turnLeft()
  10. turtle.forward()
  11. turtle.turnRight()
  12. end
  13. end
  14.  
  15. function move_to_position(sx,sy,sz,x,y,z)
  16. x_found = false
  17. y_found = false
  18. z_found = false
  19.  
  20. //moving on y axis first
  21. if sy > y then
  22. turtle.down()
  23. elseif sy < y then
  24. turtle.up()
  25. elseif sy == y then
  26. y_found = true
  27.  
  28. //moving on x axis second
  29. if y_found then
  30. if sx > x then
  31. strafe("left")
  32. elseif sx < x then
  33. strafe("right")
  34. elseif sx == x then
  35. x_found = true
  36.  
  37. //moving on z axis third
  38. if x_found then
  39. if sz > z then
  40. turtle.forward()
  41. elseif sz < z then
  42. turtle.back()
  43. elseif sz == z then
  44. z_found = true
  45.  
  46.  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement