Advertisement
brensen11

Tree

May 29th, 2022 (edited)
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local m = require( "blib" )
  2. local sapling = "minecraft:oak_sapling"
  3. local bonemeal = "minecraft:bone_meal"
  4. local log = "minecraft:oak_log"
  5.  
  6. function Main()
  7.     while( m.GetItemIndex(sapling) ) do
  8.  
  9.         if( not m.CheckFuel(30) ) then
  10.             print( "Out of fuel" )
  11.             return
  12.         end
  13.  
  14.         local boneSlot = m.GetItemIndex(bonemeal)
  15.         local sapSlot = m.GetItemIndex( sapling )
  16.  
  17.         -- BONE CHECK / 'refuel bones'
  18.         -- SAP CHECK / 'refuel saps'
  19.         -- CHECK FULL?
  20.  
  21.  
  22.  
  23.         if(boneSlot ~= nil) then
  24.             turtle.select(boneSlot)
  25.             while( turtle.place() )do
  26.                 if( turtle.getItemCount() == 0 ) then
  27.                     boneSlot = m.GetItemIndex(bonemeal)
  28.                     if( boneSlot == nil ) then
  29.                         print( "Out of bonemeal" ) -- Try getting more bonemeal from a chest or sum
  30.                         return
  31.                     end
  32.                 end
  33.             end
  34.             redstone.setOutput("back", true)
  35.             os.sleep(1)
  36.             redstone.setOutput("back", false)
  37.  
  38.             turtle.dig()
  39.             turtle.forward()
  40.             local success, data = turtle.inspectUp()
  41.             while( data.name == log ) do
  42.                 turtle.digUp()
  43.                 turtle.up()
  44.                 success, data = turtle.inspectUp()
  45.             end
  46.             success, data = turtle.inspectDown()
  47.             while(data.name ~= "minecraft:dirt") do
  48.                 turtle.down()
  49.                 success, data = turtle.inspectDown()
  50.             end
  51.             turtle.back()
  52.            
  53.             if( sapSlot ~= nil ) then
  54.                 turtle.select( sapSlot )
  55.                 turtle.place()
  56.             end
  57.         end
  58.  
  59.     end
  60. end
  61.  
  62.  
  63. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement