Advertisement
mathiaas

ftbTree

Jan 8th, 2020 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. path = 16
  2. direction = 0
  3. _sleep = 70-path
  4.  
  5. function plant()
  6.   turtle.select(1)
  7.   sapling = {}
  8.   sapling, sapling.count = turtle.getItemDetail(1)
  9.  
  10.   if (sapling.count <= 1) then
  11.     for i = 3,16 do
  12.       if (turtle.getItemDetail(i)) then
  13.         if (turtle.getItemDetail(i).name == sapling.name) then
  14.           turtle.select(i)
  15.           turtle.transferTo(1)
  16.           plant()
  17.           break
  18.         end
  19.       end
  20.     end
  21.   elseif (turtle.detect() == false) then
  22.     turtle.place()
  23.   end
  24. end
  25.  
  26. function detect()
  27.   turtle.select(2)
  28.   if (turtle.compare()) then
  29.     felling()
  30.   else
  31.     plant()
  32.   end
  33. end
  34.  
  35. function felling()
  36.   turtle.dig()
  37.   turtle.forward()
  38.   while (turtle.detectUp()) do
  39.     turtle.digUp()
  40.     turtle.up()
  41.     for i = 1,4 do
  42.       turtle.dig()
  43.       turtle.turnRight()
  44.     end
  45.   end
  46.   goDown()
  47. end
  48.  
  49. function goDown()
  50.   turtle.back()
  51.   while turtle.down() do
  52.     for i = 1,4 do
  53.       turtle.dig()
  54.       turtle.turnRight()
  55.     end
  56.   end
  57.  
  58.   if (turtle.inspectDown()) then
  59.     local block, type = turtle.inspectDown()
  60.     if (type.name ~= "minecraft:dirt" and type.name ~= "minecraft:grass" and type.name ~= "minecraft:chest") then
  61.       turtle.digDown()
  62.       goDown()
  63.     end
  64.   end
  65. end
  66.  
  67. function pathing()
  68.   for x = 2,path do
  69.     detect()
  70.    
  71.     if (direction == 1) then
  72.       turtle.turnRight()
  73.       turtle.suck()
  74.       turtle.forward()
  75.       turtle.turnLeft()
  76.     else
  77.       turtle.turnLeft()
  78.       turtle.suck()
  79.       turtle.forward()
  80.       turtle.turnRight()
  81.     end
  82.    
  83.     detect()
  84.   end
  85.  
  86.   if (direction == 1) then
  87.     direction = 0
  88.     bank()
  89.   else
  90.     direction = 1
  91.   end
  92. end
  93.  
  94. function bank()
  95.   for z = 3,15 do
  96.     turtle.select(z)
  97.     turtle.transferTo(1)
  98.     if (turtle.dropDown() == false and turtle.getItemCount() > 0) then
  99.       while (true) do
  100.         turtle.turnRight()
  101.       end
  102.     end
  103.   end
  104. end
  105.  
  106. function main()
  107.    while (true) do
  108.      pathing()
  109.      sleep(_sleep)
  110.    end
  111. end
  112.  
  113. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement