jseely

Turtle

Nov 15th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. function turn(direction, times)
  2. times = times or 1
  3. for i = 1, times, 1 do
  4. if direction == "right" then
  5. turtle.turnRight()
  6. elseif direction == "left" then
  7. turtle.turnLeft()
  8. end
  9. end
  10. end
  11.  
  12. function swapRowDirection(currentDir)
  13. if currentDir == "right" then
  14. currentDir = "left"
  15. else
  16. currentDir = "right"
  17. end
  18. end
  19.  
  20. function swapColDirection(currentDir)
  21. if currentDir == "up" then
  22. currentDir = "down"
  23. else
  24. currentDir = "up"
  25. end
  26. end
  27.  
  28. function sForward(times)
  29. times = times or 1
  30. for i = 1, times, 1 do
  31. if not turtle.forward() then
  32. return i - 1
  33. end
  34. end
  35. return times
  36. end
  37.  
  38. function sUp(times)
  39. times = times or 1
  40. for i = 1, times, 1 do
  41. if not turtle.up() then
  42. return i - 1
  43. end
  44. end
  45. return times
  46. end
  47.  
  48. function sDown(times)
  49. times = times or 1
  50. for i = 1, times, 1 do
  51. if not turtle.down() then
  52. return i - 1
  53. end
  54. end
  55. return times
  56. end
Advertisement
Add Comment
Please, Sign In to add comment