bldng1

tree

Jul 30th, 2022 (edited)
1,411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. delay=0.05
  2.  
  3. while(true) do
  4.     local success, ydata = turtle.inspect()
  5.     if not success then
  6.         ydata = {name=""}
  7.     end
  8.     while not (string.find(ydata.name,"sapling")==nil) do
  9.         turtle.suck()
  10.         success, ydata = turtle.inspect()
  11.         if not success then
  12.             ydata = {name=""}
  13.         end
  14.     end
  15.     print("digging")
  16.     while not turtle.forward() do
  17.         turtle.dig()
  18.         turtle.attack()
  19.         print("sleep")
  20.         sleep(delay)
  21.     end
  22.     print("moved forward")
  23.     success, ydata = turtle.inspectUp()
  24.     if not success then
  25.         ydata = {name=""}
  26.     end
  27.     while not (string.find(ydata.name,"log")==nil) do
  28.         while not turtle.up() do
  29.             turtle.digUp()
  30.             sleep(delay)
  31.         end
  32.         success, ydata = turtle.inspectUp()
  33.         if not success then
  34.             ydata = {name=""}
  35.         end
  36.     end
  37.     print("mined oak")
  38.     while not turtle.detectDown() do
  39.         turtle.down()
  40.     end
  41.     print("moved down")
  42.     turtle.back()
  43.     saplingcount=0
  44.     for i=1,16 do
  45.         if turtle.getItemCount(i) > 0 then
  46.             item=turtle.getItemDetail(i).name
  47.             print(item)
  48.             if not (string.find(item,"sapling")==nil) then
  49.                 if saplingcount>60 then
  50.                     turtle.select(i)
  51.                     while turtle.dropDown() == false and turtle.getItemCount() ~= 0 do -- Waits until turtle can deposit item
  52.                         sleep(1)
  53.                     end
  54.                 else
  55.                     saplingcount=saplingcount+turtle.getItemCount(i)
  56.                     turtle.select(i)
  57.                     turtle.transferTo(1)
  58.                 end
  59.             else
  60.                 turtle.select(i)
  61.                 while turtle.dropDown() == false and turtle.getItemCount() ~= 0 do -- Waits until turtle can deposit item
  62.                     sleep(1)
  63.                 end
  64.             end
  65.         end
  66.     end
  67.     turtle.select(1)
  68.     turtle.place()
  69. end
Advertisement
Add Comment
Please, Sign In to add comment