Advertisement
mathiaas

ftbspeedfarm

Jan 21st, 2020 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. crop = "minecraft:wheat"
  2. seed = "minecraft:wheat_seeds"
  3. fertilizer = "Forestry:fertilizerCompound"
  4.  
  5. function depoCrops()
  6.   for i = 1,16 do
  7.     if (turtle.getItemDetail(i)) then
  8.       data = turtle.getItemDetail(i)
  9.       if (data.name == crop) then
  10.         turtle.select(i)
  11.         turtle.drop()
  12.       end
  13.     end
  14.   end
  15. end
  16.  
  17. function organize()
  18.   inventory = {}
  19.   for i = 1,16 do
  20.     if (turtle.getItemDetail(i) ~= nil) then
  21.       data = turtle.getItemDetail(i)
  22.       data["slot"] = i
  23.       _match = false
  24.       for key, value in pairs(inventory) do
  25.         if (inventory[key].name == data.name) then
  26.           _match = true
  27.           turtle.select(i)
  28.           turtle.transferTo(inventory[key].slot)
  29.         end
  30.       end
  31.       if (_match == false) then
  32.         table.insert(inventory,data)
  33.       end
  34.     end
  35.   end
  36.  
  37.   for i = 1,16 do
  38.     if (turtle.getItemDetail(i) == nil) then
  39.       j = 16
  40.       while j > i do
  41.         if (turtle.getItemDetail(j)) then
  42.           turtle.select(j)
  43.           turtle.transferTo(i)
  44.           break
  45.         end
  46.         j = j - 1
  47.       end
  48.     end
  49.   end
  50. end
  51.  
  52. function dropSeeds()
  53.   _match = false
  54.   for i = 1,16 do
  55.     if (turtle.getItemDetail(i)) then
  56.       data = turtle.getItemDetail(i)
  57.       if (data.name == seed) then
  58.         if (_match == false) then
  59.           _match = true
  60.         else
  61.           turtle.select(i)
  62.           turtle.dropDown()
  63.         end
  64.       end
  65.     end
  66.   end
  67. end
  68.  
  69. function refill()
  70.   turtle.select(2)
  71.   for i = 1,3 do
  72.     turtle.suckUp()
  73.   end
  74. end
  75.  
  76. function plant()
  77.   for i = 1,16 do
  78.     if (turtle.getItemDetail(i)) then
  79.       data = turtle.getItemDetail(i)
  80.       if (data.name == seed) then
  81.         turtle.select(i)
  82.         turtle.placeDown()
  83.         break;
  84.       end
  85.     end
  86.   end
  87. end
  88.  
  89. function selectFertilizer()
  90.   for i = 1,16 do
  91.     if (turtle.getItemDetail(i)) then
  92.       data = turtle.getItemDetail(i)
  93.       if (data.name == fertilizer) then
  94.         turtle.select(i)
  95.         break;
  96.       end
  97.     end
  98.   end
  99. end
  100.  
  101. function impregnate()
  102.   if (turtle.inspectDown()) then
  103.     local succ,data = turtle.inspectDown()
  104.     while (data.metadata ~= 7) do
  105.       if (checkFert() == false) then
  106.         refill()
  107.       end
  108.       selectFertilizer()
  109.       turtle.placeDown()
  110.       succ,data = turtle.inspectDown()
  111.     end
  112.     turtle.digDown()
  113.     plant()
  114.   end
  115. end
  116.  
  117. function checkFull()
  118.   _match = true
  119.   for i = 1,16 do
  120.     if (turtle.getItemCount(i) == 0) then
  121.       _match = false
  122.     end
  123.   end
  124.   return _match
  125. end
  126.  
  127. function checkFert()
  128.   _match = false
  129.   for i = 1,16 do
  130.     if (turtle.getItemDetail(i)) then
  131.       data = turtle.getItemDetail(i)
  132.       if (data.name == fertilizer) then
  133.         _match = true
  134.       end
  135.     end
  136.   end
  137.   return _match
  138. end
  139.  
  140.  
  141. function cleanUp()
  142.   organize()
  143.   dropSeeds()
  144.   depoCrops()
  145. end
  146.  
  147. while true do
  148.   if (checkFull()) then
  149.     cleanUp()
  150.   end
  151.   impregnate()
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement