mathiaas

ftbMine

Jan 8th, 2020 (edited)
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 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.   for i = 2,16 do
  54.     if (turtle.getItemDetail(i)) then
  55.       data = turtle.getItemDetail(i)
  56.       if (data.name == seed) then
  57.         turtle.select(i)
  58.         turtle.dropDown()
  59.       end
  60.     end
  61.   end
  62. end
  63.  
  64. function refill()
  65.   turtle.select(2)
  66.   for i = 1,3 do
  67.     turtle.suckUp()
  68.   end
  69. end
  70.  
  71. function plant()
  72.   for i = 1,16 do
  73.     if (turtle.getItemDetail(i)) then
  74.       data = turtle.getItemDetail(i)
  75.       if (data.name == seed) then
  76.         turtle.select(i)
  77.         turtle.placeDown()
  78.         break;
  79.       end
  80.     end
  81.   end
  82. end
  83.  
  84. function selectFertilizer()
  85.   for i = 1,16 do
  86.     if (turtle.getItemDetail(i)) then
  87.       data = turtle.getItemDetail(i)
  88.       if (data.name == fertilizer) then
  89.         turtle.select(i)
  90.         break;
  91.       end
  92.     end
  93.   end
  94. end
  95.  
  96. function impregnate()
  97.   if (turtle.inspectDown()) then
  98.     local succ,data = turtle.inspectDown()
  99.     while (data.metadata ~= 7) do
  100.       selectFertilizer()
  101.       turtle.placeDown()
  102.     end
  103.     turtle.digDown()
  104.   end
  105. end
  106.  
  107. function checkFull()
  108.   _match = true
  109.   for i = 1,6 do
  110.     if (turtle.getItemCount(i) == 0) then
  111.       _match = false
  112.     end
  113.   end
  114.   return _match
  115. end
  116.  
  117.  
  118. function cleanUp()
  119.   organize()
  120.   dropSeeds()
  121.   depoCrops()
  122.   refill()
  123. end
  124. --dropSeeds()
  125. --depoCrops()
  126. --refill()
  127. --plant()
  128. --impregnate()
  129.  
  130. while true do
  131.   if (checkFull()) then
  132.     cleanUp()
  133.   end
  134.   plant()
  135.   impregnate()
  136. end
Advertisement
Add Comment
Please, Sign In to add comment