Advertisement
Oeb25

Untitled

Sep 21st, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. local slots = {
  2. seeds = 1,
  3. bonemeal = 2,
  4. fuel = 3
  5. }
  6. local waitTill
  7. waitTill = function(condition, compare, callback)
  8. if compare == nil then
  9. compare = true
  10. end
  11. while condition() ~= compare do
  12. if callback then
  13. callback()
  14. end
  15. os.sleep(0.1)
  16. end
  17. return true
  18. end
  19. local fuel
  20. fuel = function(amount)
  21. if amount == nil then
  22. amount = 100
  23. end
  24. local old = 1
  25. while turtle.getFuelLevel() < amount do
  26. print('Fuel level to low, put fuel in slot 16')
  27. turtle.select(slots.fuel)
  28. turtle.refuel()
  29. os.sleep(1)
  30. end
  31. return turtle.select(old)
  32. end
  33. local forward
  34. forward = function(steps)
  35. if steps == nil then
  36. steps = 1
  37. end
  38. if steps < 1 then
  39. return true
  40. end
  41. fuel()
  42. waitTill(turtle.forward, true)
  43. return forward(steps - 1)
  44. end
  45. local up
  46. up = function(steps)
  47. if steps == nil then
  48. steps = 1
  49. end
  50. if steps < 1 then
  51. return true
  52. end
  53. fuel()
  54. waitTill(turtle.up, true)
  55. return up(steps - 1)
  56. end
  57. local down
  58. down = function(steps)
  59. if steps == nil then
  60. steps = 1
  61. end
  62. if steps < 1 then
  63. return true
  64. end
  65. fuel()
  66. waitTill(turtle.down, true)
  67. return down(steps - 1)
  68. end
  69. local emptyDown
  70. emptyDown = function(first, last)
  71. if first == nil then
  72. first = 1
  73. end
  74. if last == nil then
  75. last = 16
  76. end
  77. for slot = first, last do
  78. turtle.select(slot)
  79. turtle.dropDown()
  80. end
  81. end
  82. local fertilize
  83. fertilize = function()
  84. local initial = turtle.getItemCount(slots.bonemeal)
  85. if initial < 2 then
  86. return false
  87. end
  88. turtle.select(slots.bonemeal)
  89. turtle.placeDown()
  90. if initial ~= turtle.getItemCount(slots.bonemeal) then
  91. fertilize()
  92. end
  93. return true
  94. end
  95. turtle.step = function()
  96. while not fertilize() do
  97. os.sleep(0.5)
  98. end
  99. turtle.select(slots.seeds)
  100. turtle.digDown()
  101. return forward()
  102. end
  103. forward()
  104. while turtle.detectDown() do
  105. step()
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement