Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ****************************************************************************
- -- ** FARM **
- -- ****************************************************************************
- local n = 0
- local refilled = false
- -- Fill the specified slot from any later slot that contains the same item, i.e. shuffle everything up to the topmost slots
- local function fillSlot(slot)
- local n = 0
- if turtle.getItemSpace(slot) > 0 and turtle.getItemCount(slot) > 0 then
- for n=16,slot+1,-1 do
- turtle.select(n)
- if turtle.compareTo(slot) then
- turtle.transferTo(slot, turtle.getItemSpace(slot))
- end
- end
- end
- end
- local function shuffleLoot()
- local n=0
- for n=1,15 do
- fillSlot(n)
- end
- end
- local function refillUp(slot)
- local n=0
- if turtle.getItemSpace(slot) > 0 then
- -- Get more bonemeal or sulfur goo from the chest
- refilled = false
- n=slot+1
- repeat
- n=n+1
- until n > 16 or turtle.getItemCount(n) == 0
- if n <= 16 then
- turtle.select(n)
- turtle.suck()
- -- don't want a full stack, so put some back
- if turtle.getItemSpace(n) == 0 then
- turtle.drop(turtle.getItemCount(2))
- end
- turtle.transferTo(slot, turtle.getItemSpace(2))
- end
- end
- end
- shuffleLoot()
- refillUp(2)
- -- Keep farming while there is still more than 1 fertilizer and free inventory space for at least 1 wheat
- while turtle.getItemCount(2) > 1 and turtle.getItemSpace(15) > 0 and turtle.getItemSpace(16) > 0 do
- while turtle.getItemCount(2) > 1 and turtle.getItemSpace(15) > 0 and turtle.getItemSpace(16) > 0 do
- -- Use all but one of the seeds and bonemeal (or sulfur goo)
- while turtle.getItemCount(1) > 1 and turtle.getItemCount(2) > 1 do
- turtle.select(1)
- turtle.placeDown()
- sleep(.1)
- turtle.select(2)
- turtle.placeDown()
- sleep(.1)
- turtle.digDown()
- turtle.suckDown()
- -- sleep(.1)
- -- turtle.suckDown()
- end
- -- Shuffle everything up to the top
- shuffleLoot()
- refillUp(2)
- end
- -- Unload into chest above, first all but one wheat in Slot 3
- turtle.select(3)
- turtle.dropUp(turtle.getItemCount(3)-1)
- -- ...then everything else that doesn't match Slot 2 (bonemeal or sulfur goo)
- for n=4,15 do
- turtle.select(n)
- if not turtle.compareTo(2) then
- turtle.dropUp()
- end
- end
- refillUp(2)
- end
- turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement