Advertisement
makmoud98

Untitled

Feb 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. SAPLING = "minecraft:sapling"--always be slot 2
  2. LOG = "minecraft:log"
  3. FUEL = "minecraft:coal"
  4. --charcoal always slot 1
  5. WIDTH = 2
  6. LENGTH = 11
  7.  
  8. DELAY = 60 -- seconds
  9.  
  10. move = 3
  11.  
  12. function dropLoot()
  13. local data = turtle.getItemDetail(1)
  14. if data and data.name ~= FUEL then
  15. turtle.dropDown(1)
  16. end
  17. for i=3,16 do
  18. turtle.dropDown(i)
  19. end
  20. end
  21.  
  22. function refuel()
  23. local data = turtle.getItemDetail(1)
  24. if data and data.name == FUEL then
  25. turtle.select(1)
  26. turtle.suckDown(64-data.count)
  27. turtle.refuel()
  28. else
  29. turtle.select(1)
  30. turtle.suckDown(64)
  31. turtle.refuel()
  32. end
  33. end
  34.  
  35. function estimateFuelNeed()
  36. return WIDTH * LENGTH * 5 * 5
  37. end
  38.  
  39. function fell()
  40. refuel()
  41. if turtle.getFuelLevel() < estimateFuelNeed() then
  42. return false
  43. end
  44. for w=1,WIDTH do
  45. for i=1,LENGTH do
  46. for j=1,move do
  47. while not turtle.forward() do
  48. turtle.dig()
  49. end
  50. end
  51. local s,d = turtle.inspectDown()
  52. local saplinginfo = turtle.getItemDetail(2)
  53. if s then
  54. if d.name == SAPLING then
  55. --keep moving, it aint done yet
  56. elseif d.name == LOG then
  57. --break all the logs and replant
  58. turtle.digDown()
  59. local count = 0
  60. local s_, d_ = turtle.inspectUp()
  61. while s_ and d_.name == LOG do
  62. turtle.digUp()
  63. turtle.up()
  64. count = count + 1
  65. s_, d_ = turtle.inspectUp()
  66. end
  67. for j=1,count do
  68. turtle.down()
  69. end
  70. turtle.select(2)
  71. turtle.placeDown()
  72. end
  73. else
  74. --there should be a sapling or a log here..
  75. --replanting anyway
  76. turtle.select(2)
  77. turtle.placeDown()
  78. end
  79. turtle.suck()
  80. if i ~= LENGTH then
  81. move = 5
  82. elseif w == WIDTH then
  83. for j=1, 3 do
  84. while not turtle.forward() do
  85. turtle.dig()
  86. end
  87. end
  88. turtle.turnRight()
  89. for j=1, 3 do
  90. while not turtle.forward() do
  91. turtle.dig()
  92. end
  93. end
  94. dropLoot()
  95. for j=1, 2 do
  96. while not turtle.forward() do
  97. turtle.dig()
  98. end
  99. end
  100. turtle.turnRight()
  101. else
  102. move = 5
  103. turtle.turnRight()
  104. for j=1, 5 do
  105. while not turtle.forward() do
  106. turtle.dig()
  107. end
  108. end
  109. turtle.turnRight()
  110. end
  111. end
  112. end
  113. return true
  114. end
  115.  
  116. while true do
  117. if not fell() then
  118. print('couldnt start, not enough fuel. need at least ' .. estimateFuelNeed())
  119. end
  120. os.sleep(DELAY)
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement