Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. -- Sheep shearing program for shearing turtle
  2. -- Fuel must be provided in a chest directly above the turtle
  3. -- Collected wool is placed in the chest directly under the turtle
  4.  
  5. cycles = 0
  6. totalwool = 0
  7.  
  8.  
  9. local function shear()
  10. turtle.attack()
  11. turtle.turnRight()
  12. turtle.attack()
  13. turtle.turnRight()
  14. turtle.attack()
  15. turtle.turnRight()
  16. turtle.attack()
  17. turtle.turnRight()
  18. end
  19.  
  20. local function updateterm()
  21. term.clear()
  22. print("---------------------------------")
  23. write("Cycles: ")
  24. write(cycles)
  25. write(" | ")
  26. write("Total Wool: ")
  27. write(totalwool)
  28. print("---------------------------------")
  29. print("")
  30. end
  31.  
  32. local function getFuel()
  33. turtle.select(16)
  34. while turtle.getItemCount(16) < 2 do
  35. redstone.setOutput("top", true)
  36. sleep(5)
  37. redstone.setOutput("top", false)
  38. turtle.suckUp(63)
  39. os.sleep(1)
  40. if turtle.getItemCount(16) < 2 then
  41. print("I need more fuel in above chest")
  42. print("Waiting 30 seconds before checking again")
  43. os.sleep(30)
  44. end
  45. end
  46. end
  47.  
  48. local function checkFuel()
  49. while turtle.getFuelLevel() < 10 do
  50. getFuel()
  51. turtle.select(16)
  52. turtle.refuel(1)
  53. end
  54. end
  55.  
  56. local function storeWool()
  57. storecheck = false
  58. -- while storecheck == false do
  59. for i=1,15,1 do
  60. if turtle.getItemCount(i) > 0 then
  61. turtle.select(i)
  62. totalwool = totalwool + turtle.getItemCount(i)
  63. storecheck = not turtle.dropDown()
  64. end
  65. end
  66. -- end
  67. if storagespace == false then
  68. print("The inventory is full I can't store my harvest")
  69. print("Waiting 30 seconds before checking again")
  70. os.sleep(30)
  71. end
  72. end
  73.  
  74. while true do
  75. checkFuel()
  76. shear()
  77. storeWool()
  78. cycles = cycles + 1
  79. updateterm()
  80. os.sleep(5)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement