deltreey icon

treefarm/single

deltreey | PRO | 02/08/15 08:01:53 AM UTC | 0 ⭐ | 418 👁️ | Never ⏰ | []
text |

880 B

|

None

|

0 👍

/

0 👎

os.loadAPI('/fuel')
 function refreshInventory()
	turtle.down()
	turtle.down()
	local current = 3
	while (current < 16) do
		turtle.select(current)
		turtle.dropDown()
		current = current + 1
	end
	turtle.select(1)
	turtle.suckDown(1)	--Get new sapling
	turtle.up()
	turtle.up()
end
 function isTree()
	turtle.select(2)
	return turtle.compare()
end
 function chopTree()
	local dist = 0
	while (turtle.detect() and dist < 15) do
		turtle.dig()
		if (turtle.detectUp()) then
			turtle.digUp()
		end
		turtle.up()
		dist = dist + 1
	end
	while (dist > 0) do
		dist = dist - 1
		turtle.down()
	end
end
 while (true) do
	if (turtle.getFuelLevel() < 100) then
		if (fuel.canRefuel()) then
			fuel.fuelUp()
		else
			print('Cannot refuel')
			break
		end
	end
	if (isTree()) then
		chopTree()
		refreshInventory()
		turtle.place()
	end
	sleep(30)
end

Comments