jseely

turtle

Nov 15th, 2012
49
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(dir, times)
  2. times = times or 1
  3. for i = 1, times, 1 do
  4. if dir == "right" then
  5. turtle.turnRight()
  6. elseif dir == "left" then
  7. turtle.turnLeft()
  8. end
  9. end
  10. end
  11.  
  12. function swapRowDir(currentDir)
  13. if currentDir == "right" then
  14. return "left"
  15. elseif currentDir == "left" then
  16. return "right"
  17. end
  18. end
  19.  
  20. function swapColDir(currentDir)
  21. if currentDir == "up" then
  22. return "down"
  23. elseif currentDir == "down" then
  24. return "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