Advertisement
Axow01

ComputerCraft Tree Farmer

Nov 25th, 2020 (edited)
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. function stop(m)
  2.     print(m)
  3.     exit()
  4. end
  5.  
  6. function plantTree(slot)
  7.     turtle.select(16)
  8.     turtle.forward()
  9.     treeDetector = turtle.detect()
  10.     turtle.back()
  11.     if not(treeDetector) then
  12.         turtle.place()
  13.     end
  14. end
  15.  
  16. function mineTree(a)
  17.     local blockFront = turtle.detect()
  18.     local tree = 0
  19.     local tree2 = 0
  20.     while blockFront == false do
  21.         blockFront = turtle.detect()
  22.         turtle.forward()
  23.         tree = tree + 1
  24.         if tree == tree2 + 3 then
  25.             tree2 = tree2 + 1
  26.             if blockFront == false then
  27.                 local aaa = turtle.detect()
  28.                 if not(aaa) then
  29.                     plantTree(16)
  30.                 end
  31.             end
  32.         end
  33.     end
  34.     if blockFront then
  35.         local blockType, data = turtle.inspect()
  36.         if blockType then
  37.             print(data.name)
  38.             if data.name == "minecraft:log" then
  39.                 local i = 0
  40.                 while blockFront do
  41.                     blockFront = turtle.detect()
  42.                     i = i + 1
  43.                     turtle.dig()
  44.                     turtle.digUp()
  45.                     turtle.up()
  46.                 end
  47.                 while i > 0 do
  48.                     i = i - 1
  49.                     turtle.down()
  50.                 end
  51.                 blockFront = turtle.detect()
  52.             end
  53.             if data.name == "minecraft:cobblestone" then
  54.                 turtle.turnLeft()
  55.                 chestFinder, data = turtle.inspect()
  56.                 if chestFinder and data.name == 'minecraft:chest' then
  57.                     local i = 1
  58.                     turtle.select(1)
  59.                     while i <= 15 do
  60.                         turtle.select(i)
  61.                         i = i + 1
  62.                         turtle.drop()
  63.                     end
  64.                     turtle.select(1)
  65.                 end
  66.                 turtle.turnLeft()
  67.             end
  68.             if data.name == 'minecraft:sapling' then
  69.                 turtle.digUp()
  70.                 turtle.up()
  71.                 turtle.dig()
  72.                 turtle.forward()
  73.                 turtle.dig()
  74.                 turtle.forward()
  75.                 turtle.digDown()
  76.                 turtle.down()
  77.             end
  78.             if data.name == 'minecraft:coal_block' then
  79.                 stop('Coal Block Stop The Machine')
  80.             end
  81.         end
  82.     end
  83.     mineTree()
  84. end
  85.  
  86. mineTree()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement