106 lines
2 KiB
Lua
106 lines
2 KiB
Lua
-- Variables
|
|
local HEIGHT = 27
|
|
local WIDTH = 6
|
|
local GROWTH_MAX = 7
|
|
local SEED_NAME = "actuallyadditions:item_rice_seed"
|
|
local CROP_NAME = "actuallyadditions:block_rice"
|
|
--
|
|
|
|
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
|
|
|
|
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 and data.name == CROP_NAME 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
|
|
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
|
|
farm()
|
|
end
|
|
|
|
if i ~= WIDTH - 1 then
|
|
if turnLeft then
|
|
turtle.turnLeft()
|
|
turtle.forward()
|
|
turtle.turnLeft()
|
|
else
|
|
turtle.turnRight()
|
|
farm()
|
|
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.")
|