Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N = 9
- M = 14
- -- END CONFIG SECTION
- seeds_count = 0
- MAX_ITEMS = 64
- for i=2,16 do
- if turtle.compareTo(i) then
- seeds_count = seeds_count + turtle.getItemCount(i)
- end
- end
- if seeds_count-16 < N*M then
- printError("Not enough seeds!")
- -- return
- end
- args = ...
- turtle.refuel(64)
- function reset_out()
- redstone.setOutput("left", false)
- redstone.setOutput("right", false)
- end
- function harvest_complete(rotation)
- if rotation == turtle.turnRight then
- redstone.setOutput("left", true)
- else
- redstone.setOutput("right", true)
- end
- os.sleep(1)
- end
- function operation(forwarded, x, y)
- -- adding to the firtst slot seeds
- if turtle.getItemCount(1) == 1 then
- for i=2,16 do
- if turtle.compareTo(i) then
- available_items = turtle.getItemCount(i)
- if available_items == MAX_ITEMS then
- available_items = available_items - 1
- end
- turtle.transferTo(1, available_items)
- end
- end
- end
- turtle.digDown()
- turtle.placeDown()
- end
- -- function defenitions
- function check_start(delay)
- while true do
- if redstone.getInput("back") == true then
- -- go_to_house()
- return
- else
- os.sleep(delay)
- end
- end
- end
- function go_to_house()
- os.sleep(2)
- -- checking position of end harvest
- if M%2 == 0 then
- -- we at the same line
- -- turtle.back()
- turtle.turnRight()
- for i=1,M do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- -- we at opposite line
- turtle.back()
- turtle.turnLeft()
- for i=1,M+1 do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,N+1 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- function run()
- return turtle.forward()
- end
- function harvest()
- local i = 0
- while i<M do
- j=0
- while j<N-1 do
- if run() then
- operation(true, i, j)
- else
- operation(false, i, j)
- j=j-1
- end
- turtle.dig()
- j=j+1
- end
- if i%2 == 0 then
- rotation = turtle.turnLeft
- else
- rotation = turtle.turnRight
- end
- rotation()
- if run() then
- operation(true, i,j)
- else
- operation(false, i,j)
- run()
- end
- rotation()
- i=i+1
- end
- reset_out()
- harvest_complete(rotation)
- end
- check_start(0.5)
- harvest()
- go_to_house()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement