Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gridSize = 7
- local potatoSlot = 1
- local fuelSlot = 16
- function refuelTurtle()
- print("Refueling...")
- turtle.select(fuelSlot)
- turtle.refuel()
- turtle.select(potatoSlot)
- end
- function isMaturePotato()
- local success, data = turtle.inspectDown()
- if success then
- print("Inspecting block:", data.name)
- if data.state and data.state.age then
- print("Crop age:", data.state.age)
- return data.name == "minecraft:potatoes" and data.state.age == 7
- else
- print("No age data found for this block.")
- end
- else
- print("No block detected below.")
- end
- return false
- end
- function harvestAndReplant()
- print("Scanning...")
- if isMaturePotato() then
- turtle.digDown()
- turtle.select(potatoSlot)
- turtle.placeDown()
- end
- end
- function scanFarm()
- for row = 1, gridSize do
- for col = 1, gridSize do
- harvestAndReplant()
- if col < gridSize then turtle.forward() end
- end
- -- Move to next row
- if row < gridSize then
- if row % 2 == 1 then turtle.turnRight() else turtle.turnLeft() end
- turtle.forward()
- if row % 2 == 1 then turtle.turnRight() else turtle.turnLeft() end
- end
- end
- end
- function returnToStart()
- -- Reverse the scan pattern to return to top-left
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, gridSize - 1 do turtle.forward() end
- turtle.turnRight()
- for i = 1, gridSize - 1 do turtle.forward() end
- turtle.turnRight()
- end
- function dumpPotatoes()
- turtle.back()
- turtle.down()
- for slot = 1, 15 do
- turtle.select(slot)
- turtle.dropDown()
- end
- turtle.up()
- turtle.forward()
- end
- -- Main loop
- while true do
- refuelTurtle()
- scanFarm()
- returnToStart()
- dumpPotatoes()
- sleep(240)
- end
Advertisement
Add Comment
Please, Sign In to add comment