Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@author thor12022
- local fieldSize = 8
- local isOdd = math.ceil(fieldSize/2) ~= (fieldSize/2)
- -- It goes forever
- while true do
- -- if we need more fuel for this pass
- --TODO update for odd
- if (isOdd and turtle.getFuelLevel() < ((fieldSize * fieldSize) + 2*fieldSize)) or (turtle.getFuelLevel() < ((fieldSize * fieldSize) + fieldSize)) then
- turtle.suckUp()
- turtle.refuel()
- end
- -- face outward
- turtle.turnLeft()
- turtle.turnLeft()
- -- loop over the rows
- local turnRight = true
- for x = 1,fieldSize,1 do
- -- loop over the columns (except the last one)
- for y = 1,fieldSize - 1,1 do
- turtle.digDown()
- turtle.placeDown()
- turtle.forward()
- end
- -- harvest the last one
- turtle.digDown()
- turtle.placeDown()
- -- all but the last row
- if x ~= fieldSize then
- -- turn right or left and change column
- if turnRight == true then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turnRight = false
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turnRight = true
- end
- end
- end
- -- face the starting point
- turtle.turnRight()
- -- go back over the row if there was an odd size
- if isOdd then
- turtle.turnRight()
- for back = 1,(fieldSize-1),1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- -- go back down the column
- for back = 1,(fieldSize-1),1 do
- turtle.forward()
- end
- -- face the chest
- turtle.turnLeft()
- --empty everything into the chest
- for slot = 1,16,1 do
- turtle.select(slot)
- -- we keep trying to dump inventory
- while turtle.getItemCount(slot) ~= 0 do
- if not turtle.drop() then
- -- if the target inventory was full, we'll try it again later
- os.sleep(10)
- end
- end
- end
- -- reset to the starting conditions
- turtle.select(1)
- -- go again in 45 minutes
- os.sleep(2400)
- end
Advertisement
Add Comment
Please, Sign In to add comment