Advertisement
rhn

Melon/pumpkin farm

rhn
Apr 22nd, 2020
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local function harvest()
  2.     while true do  
  3.         if turtle.forward() then
  4.             turtle.digDown()
  5.         else
  6.             return
  7.         end
  8.     end
  9. end
  10.  
  11. local function home()
  12.     while true do  
  13.         if turtle.back()==false then
  14.             return
  15.         end
  16.     end
  17. end
  18.  
  19. local function unload()
  20.     local emptyslot=0
  21.     local maxcount=0
  22.     for i=1,16 do
  23.         turtle.select(i)
  24.         itemdata=turtle.getItemDetail()
  25.         if itemdata==nil then
  26.             emptyslot=emptyslot+1
  27.         else
  28.             if itemdata.count>maxcount then
  29.                 maxcount=itemdata.count
  30.             end
  31.         end
  32.     end
  33.     if emptyslot<3 and maxcount>50 then
  34.         for i=1,16 do
  35.             turtle.select(i)
  36.             turtle.dropDown()
  37.         end
  38.         turtle.select(1)
  39.     end
  40. end
  41.  
  42.  
  43. sleep(math.random(1,5))
  44. home()
  45.  
  46. while true do
  47.     harvest()
  48.     home()
  49.     unload()
  50.     for i=5,1,-1 do
  51.         print(i.." minute(s) to go")
  52.         sleep(60)
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement