Epuuc

Minecraft CC Auto-Farm Def-16x16

Dec 1st, 2020 (edited)
1,391
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Config
  2. local dwidth = 16
  3. local ddepth = 16
  4. local dtimer = 24 -- In minutes (Crops should grow in like 24 min)
  5. local seeds = {"seed","cotton"} -- Insert seed names here (For example Wheat Seed has 'seed' in it, so you don't need to add it)
  6.  
  7. --Setting variables to defaults
  8. local width = dwidth
  9. local depth = ddepth
  10. local dtimer = dtimer
  11.  
  12. --Argument Handling
  13. local args = {...}
  14. print("Auto-Farm:")
  15. if args[1] and tonumber(args[1]) ~= nil then
  16.     width = tonumber(args[1])
  17.     print("X:",args[2])
  18. else
  19.     print("X:",dwidth,"(Default)")
  20. end
  21. if args[2] and tonumber(args[2]) ~= nil then
  22.     depth = tonumber(args[2])
  23.     print("Z:",args[2])
  24. else
  25.     print("Z:",ddepth,"(Default)")
  26. end
  27. if args[3] and tonumber(args[3]) ~= nil then
  28.     timer = tonumber(args[3])
  29.     print("Timer:",tonumber(args[3]))
  30. else
  31.     print("Timer:",dtimer,"(Default)")
  32. end
  33.  
  34. -- Edited built in functions
  35. local turt = {
  36.     forward = function()
  37.         local fueltypes = {"coal","charcoal","lava"}
  38.         if turtle.getFuelLevel() <= 0 then
  39.             print("Panik! No Fuel!")
  40.         end
  41.         while true do
  42.             if turtle.getFuelLevel() > 0 then
  43.                 break
  44.             end
  45.             for i=1,16 do
  46.                 local data = turtle.getItemDetail(i)
  47.                 for ind=1,#fueltypes do
  48.                     if data and string.find(data.name,fueltypes[ind]) then
  49.                         turtle.select(ind)
  50.                         turtle.refuel(turtle.getItemCount(ind))
  51.                     end
  52.                 end
  53.             end
  54.         end
  55.         while not turtle.forward() do
  56.             turtle.dig()
  57.         end
  58.     end,
  59.     lookFor = function(list)
  60.         if not list then error("Table required for argument 2") end
  61.         for i=1,16 do
  62.             local data = turtle.getItemDetail(i)
  63.             for ind=1,#list do
  64.                 if data and string.find(data.name,list[ind]) then
  65.                     return ind
  66.                 end
  67.             end
  68.         end
  69.     end
  70. }
  71.  
  72. local function placeSeed()
  73.     local seedslot = turt.lookFor(seeds)
  74.     if seedslot and seedslot ~= turtle.getSelectedSlot() then
  75.         print(seedslot)
  76.         turtle.select(seedslot)
  77.     elseif not seedslot then
  78.         print("Panik! No Seeds!")
  79.         while not turt.lookFor(seeds) do
  80.             sleep(1)
  81.         end
  82.         turtle.select(turt.lookFor(seeds))
  83.     end
  84.     turtle.placeDown()
  85.     turtle.suckDown()
  86. end
  87.  
  88. --Farm Circuit
  89. local function farmCircuit()
  90.     turtle.up()
  91.     turt.forward()
  92.     turtle.digDown()
  93.     turtle.suckDown()
  94.     placeSeed()
  95.     turtle.turnRight()
  96.     for z=1,depth do
  97.         for x=1,width-1 do
  98.             turt.forward()
  99.             turtle.digDown()
  100.             turtle.suckDown()
  101.             placeSeed()
  102.         end
  103.         if z ~= depth then
  104.             if z % 2 == 0 and  then
  105.                 turtle.turnRight()
  106.                 turt.forward()
  107.                 turtle.turnRight()
  108.             else
  109.                 turtle.turnLeft()
  110.                 turt.forward()
  111.                 turtle.turnLeft()
  112.             end
  113.             turtle.digDown()
  114.             turtle.suckDown()
  115.             placeSeed()
  116.         else
  117.            
  118.         end
  119.     end
  120.    
  121. end
  122.  
  123. --Checking for an instant start arg or not
  124. if args[4] then
  125.     while true do
  126.         farmCircuit()
  127.         sleep(dtimer*60)
  128.     end
  129. else
  130.     while sleep(dtimer*60) do
  131.         farmCircuit()
  132.     end
  133. end
  134.  
  135.  
RAW Paste Data