Upload files to 'crop-farm'

This commit is contained in:
Jan 2021-06-13 13:43:07 +00:00
parent 2d36ee2636
commit 893bd7ca49

100
crop-farm/farm.lua Normal file
View file

@ -0,0 +1,100 @@
-- Variablen
local HEIGHT = 27
local WIDTH = 6
local GROWTH_MAX = 7
local SEED_NAME = "actuallyadditions:item_rice_seed"
--
if WIDTH % 2 ~= 0 then
WIDTH = WIDTH + 1
end
function refuel()
if turtle.getFuelLevel() < 100 then
turtle.select(1)
local data = turtle.getItemDetail()
if data then
if data.count > 1 then
turtle.refuel(1)
else
print("Awaiting refuel")
sleep(5)
refuel() -- RECURSION BABY
end
end
end
end
print("Started. "..HEIGHT.."x"..WIDTH.." area; Growth level "..GROWTH_MAX..".")
-- Pull fuel from attached top inventory
if true then
turtle.select(1)
local data = turtle.getItemDetail()
if data then
local count = 64 - data.count
if count > 0 then
turtle.suckUp(count)
end
end
end
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
end
if i ~= WIDTH - 1 then
if turnLeft then
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
else
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
turnLeft = not turnLeft
else
turtle.turnRight()
for j = 1, WIDTH - 1, 1 do
refuel()
turtle.forward()
end
turtle.turnRight()
end
end
for i = 3, 16 do
turtle.select(i)
turtle.dropDown()
end
print("Done.")