kerrnel

Shearman 2.0

May 20th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. -- Shearman 2.0
  2. -- by MCKerrnel
  3. --
  4. -- A ComputerCraft program to shear
  5. -- sheep.
  6.  
  7. function goForward(blocks)
  8. for count = 1, blocks, 1 do
  9. turtle.forward()
  10. turtle.suck()
  11. end
  12. end
  13.  
  14. function turn(direction)
  15. if direction == "left" then
  16. turtle.turnLeft()
  17. else
  18. turtle.turnRight()
  19. end
  20. end
  21.  
  22. function shearCycle(direction)
  23. if direction == "left" then
  24. returndir = "right"
  25. else
  26. returndir = "left"
  27. end
  28.  
  29. -- Chest to Start of Row
  30. turn(direction)
  31. goForward(3)
  32. turn(direction)
  33.  
  34. -- Shear Row
  35. for count = 1, 8, 1 do
  36. shearPen(direction)
  37. end
  38.  
  39. -- Return to Chest
  40. turtle.turnLeft()
  41. turtle.turnLeft()
  42. goForward(23)
  43. turn(returndir)
  44. goForward(3)
  45. turn(returndir)
  46.  
  47. -- Unload
  48. for slot = 2, 16, 1 do
  49. turtle.select(slot)
  50. turtle.drop()
  51. end
  52.  
  53. turtle.turnLeft()
  54. turtle.turnLeft()
  55.  
  56. end
  57.  
  58. function shearPen(direction)
  59. turtle.select(1)
  60. for count = 1, 2, 1 do
  61. turtle.forward()
  62. turn(direction)
  63. turtle.place()
  64. os.sleep(2)
  65. turtle.suck()
  66. if direction == "left" then
  67. turtle.turnRight()
  68. else
  69. turtle.turnLeft()
  70. end
  71. end
  72. turtle.forward()
  73. end
  74.  
  75. -- MAINLINE
  76. -- This is where it all happens.
  77. while true do
  78. -- Shear North Row
  79. shearCycle("left")
  80.  
  81. -- Shear South Row
  82. shearCycle("right")
  83.  
  84. -- Wait 2 minutes to allow
  85. -- sheep to regrow wool.
  86. os.sleep(120)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment