---- -- Parameters ---- stump_dist = 32 stump_lighting = 3 stump_current = 0 branch_dist = 32 branch_lighting = 7 branch_current = 0 return_dist = 0 function mine() while turtle.detect() do turtle.dig() sleep(0.5) end end function mine_up() while turtle.detectUp() do turtle.digUp() sleep(0.5) end end function check_fuel() term.clear() term.setCursorPos(1,1) if turtle.getFuelLevel() <= 0 then print("Looking for fuel...") for i = 1,16 do turtle.select(i) turtle.refuel() break end end if turtle.getFuelLevel() <= 0 then print("Could not fuel up...") sleep(30) check_fuel() end end function forward() check_fuel() if not turtle.forward() then for i = 1,16 do turtle.select(i) item = turtle.getItemDetail() if item ~= nil then if not string.find(item["name"], "torch") or not string.find(item["name"], "chest") then turtle.placeDown() break end end forward() end end end function backwards() check_fuel() turtle.back() end function torch() s = false i = 1 for i = 1,16 do turtle.select(i) item = turtle.getItemDetail() if item ~= nil then if string.find(item["name"], "torch") then turtle.select(i) turtle.placeUp() s = true break end end end if not s then print("Could not place a torch...") end end function torch_stump() if stump_current % stump_lighting == 0 or stump_current == 0 then torch() end end function torch_branch() if branch_current % branch_lighting == 0 or branch_current == 0 then turtle.turnRight() torch() turtle.turnLeft() end end function check_inventory() for i = 1,16 do if turtle.getItemSpace(i) > 0 then return false end end return true end function storage_check() if not check_inventory() then return_dist = branch_current return_stump() forward() turtle.turnRight() mine() forward() turtle.digDown() for i = 1,16 do turtle.select(i) item = turtle.getItemDetail() if item ~= nil then if string.find(item["name"], "chest") then if turtle.getItemCount() > 1 then mine() forward() turtle.digDown() turtle.placeDown() backwards() end turtle.placeDown() end end end for i = 1,16 do turtle.select(i) item = turtle.getItemDetail() if item ~= nil then if not string.find(item["name"], "torch") or not string.find(item["name"], "chest") then turtle.dropDown() end end end backwards() turtle.turnRight() branch_current = return_dist - 1 return_stump() turtle.turnRight() turtle.turnRight() branch_current = return_dist end end function create_stump() mine() forward() mine_up() turtle.turnRight() mine() forward() mine_up() torch_stump() backwards() turtle.turnLeft() stump_current = stump_current + 1 end function return_stump() while branch_current ~= 0 do backwards() branch_current = branch_current - 1 end end function mine_branch() while branch_current ~= branch_dist do check_inventory() mine() forward() mine_up() torch_branch() branch_current = branch_current + 1 end return_stump() turtle.turnRight() turtle.turnRight() forward() while branch_current ~= branch_dist do check_inventory() mine() forward() mine_up() torch_branch() branch_current = branch_current + 1 end return_stump() backwards() turtle.turnLeft() end function initialize_branch() turtle.turnLeft() mine_branch() end stump_branching = 2 while stump_current ~= stump_dist do create_stump() if stump_branching == 3 then initialize_branch() stump_branching = 0 end stump_branching = stump_branching + 1 end