shear.lua

by hugeblank
568 days ago
COPY
1
function checkFuel()
2
	if turtle.getFuelLevel()<1 then
3
		turtle.up()
4
		while not turtle.refuel() do 
5
			sleep(2) 
6
		end
7
		turtle.down()
8
	end
9
end
10

11
while true do
12
	while turtle.forward() do
13
		checkFuel()
14
		while turtle.placeDown() do end
15
	end
16
	local _, chest = turtle.inspect()
17
	if chest and (chest.name:find("chest") or chest.name:find("barrel")) then
18
		for i = 2, 16 do
19
			turtle.select(i)
20
			turtle.drop()
21
		end
22
		turtle.select(1)
23
		local shears = turtle.getItemDetail()
24
		if not (shears and shears.name == "minecraft:shears") then
25
			turtle.suck(1)
26
			shears = turtle.getItemDetail()
27
			assert(shears and shears.name == "minecraft:shears", "Shears required to run!")
28
		end
29
	end
30
	turtle.turnLeft()
31
	turtle.turnLeft()
32
end
33