Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- farmLength = 19
- farmWidth = 8
- function fuel()
- if turtle.getFuelLevel() < 1 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function move(d, n)
- n = n or 1
- for i=1,n do
- fuel()
- d()
- end
- end
- function harvest()
- local success, data = turtle.inspectDown()
- if success then
- if data.state.age == 7 then
- turtle.digDown()
- turtle.select(2)
- if turtle.getItemCount() > 1 then
- turtle.placeDown()
- end
- end
- end
- end
- function harvestRow()
- harvest()
- for i=2, farmLength do
- move(turtle.forward)
- harvest()
- end
- end
- turnAround = {
- [0] = turtle.turnLeft,
- [1] = turtle.turnRight
- }
- function run()
- move(turtle.forward)
- for row=1, farmWidth do
- harvestRow()
- if row < farmWidth then
- turnAround[row % 2]()
- move(turtle.forward)
- turnAround[row % 2]()
- elseif row % 2 == 1 then
- turtle.turnRight()
- turtle.turnRight()
- move(turtle.forward,farmLength-1)
- end
- end
- turtle.turnRight()
- move(turtle.forward,farmWidth-1)
- turtle.turnRight()
- move(turtle.back)
- for i=3,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- local alarm = os.setAlarm(5)
- while true do
- local evt, arg = os.pullEvent("alarm")
- if arg == alarm then
- run()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement