Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function isGrown()
- local inspected, data = turtle.inspectDown()
- return (inspected and data["state"]["age"] == 7)
- end
- local function farmTile()
- turtle.digDown()
- turtle.select(1)
- turtle.placeDown()
- end
- local function empty()
- for i = 2, 15, 1 do
- turtle.select(i)
- turtle.drop(turtle.getItemCount(i))
- end
- turtle.select(1)
- end
- local function orientTurtle()
- local count = 0
- while count < 2 do
- if turtle.detect() then
- if peripheral.hasType("front", "inventory") then
- empty()
- end
- count = count + 1
- end
- if count >= 2 then
- break
- end
- turtle.turnRight()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function farmField()
- local direction = true
- local function turn(update)
- update = update or false
- if direction then
- turtle.turnLeft()
- if update then
- direction = false
- end
- else
- turtle.turnRight()
- if update then
- direction = true
- end
- end
- end
- local function farmWhenGrown()
- if isGrown() then
- print("found grown tile")
- farmTile()
- end
- end
- while true do
- farmWhenGrown()
- while not turtle.detect() do
- turtle.forward()
- farmWhenGrown()
- end
- turn()
- if not turtle.forward() then
- break
- end
- turn(true)
- end
- end
- local function refuel()
- turtle.select(16)
- local count = turtle.getItemCount(16)
- turtle.refuel(count)
- turtle.select(1)
- end
- while true do
- print("farming field")
- refuel()
- orientTurtle()
- farmField()
- print("waiting for 120 seconds")
- sleep(120)
- end
Advertisement
Add Comment
Please, Sign In to add comment