Upload files to 'crop-farm'

master
Jan 2021-06-13 14:00:15 +00:00
parent 893bd7ca49
commit ffbaeb3a71
1 changed files with 30 additions and 26 deletions

View File

@ -25,6 +25,34 @@ function refuel()
end
end
function farm()
refuel()
turtle.forward()
local success, data = turtle.inspectDown()
if not success and data ~= "No block to inspect" then
print("Failed to get block info: "..data)
end
if success and data.metadata >= GROWTH_MAX then
turtle.digDown()
end
local item = turtle.getItemDetail(2)
if item and item.name ~= SEED_NAME then
print("Invalid item in slot 2")
print("Wanted: "..SEED_NAME)
print("Found: "..item.name)
print("")
sleep(15)
elseif not item or item.count == 1 then
print("Not enough crops left; Cannot plant")
else
turtle.select(2)
turtle.placeDown()
end
end
print("Started. "..HEIGHT.."x"..WIDTH.." area; Growth level "..GROWTH_MAX..".")
-- Pull fuel from attached top inventory
@ -43,31 +71,7 @@ local turnLeft = false
for i = 0, WIDTH - 1 do
for j = 0, HEIGHT - 1 do
refuel()
turtle.forward()
local success, data = turtle.inspectDown()
if not success and data ~= "No block to inspect" then
print("Failed to get block info: "..data)
end
if success and data.metadata >= GROWTH_MAX then
turtle.digDown()
end
local item = turtle.getItemDetail(2)
if item and item.name ~= SEED_NAME then
print("Invalid item in slot 2")
print("Wanted: "..SEED_NAME)
print("Found: "..item.name)
print("")
sleep(15)
elseif not item or item.count == 1 then
print("Not enough crops left; Cannot plant")
else
turtle.select(2)
turtle.placeDown()
end
farm()
end
if i ~= WIDTH - 1 then
@ -77,7 +81,7 @@ for i = 0, WIDTH - 1 do
turtle.turnLeft()
else
turtle.turnRight()
turtle.forward()
farm()
turtle.turnRight()
end
turnLeft = not turnLeft