Advertisement
PhilHibbs

Untitled

Jan 30th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. -- ****************************************************************************
  2. -- **                                FARM                                    **
  3. -- ****************************************************************************
  4.  
  5. local n = 0
  6. local refilled = false
  7.  
  8. -- Fill the specified slot from any later slot that contains the same item, i.e. shuffle everything up to the topmost slots
  9. local function fillSlot(slot)
  10.  
  11.    local n = 0
  12.  
  13.    if turtle.getItemSpace(slot) > 0 and turtle.getItemCount(slot) > 0 then
  14.       for n=slot+1,16 do
  15.          turtle.select(n)
  16.          if turtle.compareTo(slot) then
  17.             turtle.transferTo(slot, turtle.getItemSpace(slot))
  18.          end
  19.       end
  20.    end
  21. end
  22.  
  23. local function shuffleLoot()
  24.    
  25.    local n=0
  26.    
  27.    for n=1,15 do
  28.       fillSlot(n)
  29.    end
  30. end
  31.  
  32. shuffleLoot()
  33.  
  34. -- Keep farming while there is still more than 1 fertilizer and free inventory space for at least 1 wheat
  35. while turtle.getItemCount(2) > 1 and turtle.getItemSpace(15) > 0 and turtle.getItemSpace(16) > 0 do
  36.  
  37.    while turtle.getItemCount(2) > 1 and turtle.getItemSpace(15) > 0 and turtle.getItemSpace(16) > 0 do
  38.       -- Use all but one of the seeds and bonemeal (or sulfur goo)
  39.       while turtle.getItemCount(1) > 1 and turtle.getItemCount(2) > 1  do
  40.          turtle.select(1)
  41.          turtle.placeDown()
  42.          sleep(.1)
  43.          turtle.select(2)
  44.          turtle.placeDown()
  45.          sleep(.1)
  46.          turtle.digDown()
  47.          turtle.suckDown()
  48. --         sleep(.1)
  49. --         turtle.suckDown()
  50.       end
  51.       -- Shuffle everything up to the top
  52.       shuffleLoot()
  53.       if turtle.getItemSpace(2) > 0 then
  54.          -- Get more bonemeal or sulfur goo from the chest
  55.          refilled = false
  56.          n=4
  57.          repeat
  58.             n=n+1
  59.          until n > 16 or turtle.getItemCount(n) == 0
  60.          if n <= 16 then
  61.             turtle.Select(n)
  62.             turtle.suck()
  63.             -- don't want a full stack, so put some back
  64.             if turtle.getItemSpace(n) == 0 then
  65.                turtle.drop(turtle.getItemCount(2))
  66.             end
  67.             turtle.transferTo(2, turtle.getItemSpace(2))
  68.          end
  69.       end
  70.    end
  71.    -- Unload into chest above, first all but one wheat in Slot 3
  72.    turtle.select(3)
  73.    turtle.dropUp(turtle.getItemCount(3)-1)
  74.    -- ...then everything else that doesn't match Slot 2 (bonemeal or sulfur goo)
  75.    for n=4,15 do
  76.       turtle.select(n)
  77.       if not turtle.compareTo(2) then
  78.          turtle.dropUp()
  79.       end
  80.    end
  81. end  
  82.  
  83. turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement