Advertisement
Pixelblob

Untitled

Nov 26th, 2022
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.65 KB | None | 0 0
  1. print("Starting!")
  2.  
  3. branchLength = 5
  4. spacing = 3
  5. trash = { "minecraft:dirt", "minecraft:sand", "minecraft:cobblestone", "minecraft:stone", "minecraft:gravel",
  6.     "chisel:basalt2", "chisel:marble2", "chisel:limestone2", "biomesoplenty:gem", "minecraft:yellow_flower",
  7.     "biomesoplenty:mushroom", "minecraft:flint", "minecraft:mossy_cobblestone", "thaumcraft:nugget", "xlfoodmod:salt",
  8.     "botania:mushroom", "thaumcraft:crystal_essence", "biomesoplenty:flower_1", "thermalfoundation:material", "extrautils2:ingredients" }
  9.  
  10. donotStore = { "minecraft:torch" }
  11.  
  12.  
  13.  
  14. function table.contains(table, element)
  15.     for _, value in pairs(table) do
  16.         if value == element then
  17.             return true
  18.         end
  19.     end
  20.     return false
  21. end
  22.  
  23. function slotsLeft()
  24.     slotsempty = 0
  25.  
  26.     for i = 1, 16, 1 do
  27.         local data = turtle.getItemDetail(i)
  28.  
  29.         if not data then
  30.             slotsempty = slotsempty + 1
  31.         end
  32.     end
  33.     return slotsempty
  34. end
  35.  
  36. function findItem(item)
  37.     for i = 1, 16, 1 do
  38.         local data = turtle.getItemDetail(i)
  39.  
  40.         if data then
  41.             if data.name == item then
  42.                 return i
  43.             end
  44.         end
  45.     end
  46.     return nil
  47. end
  48.  
  49. torchInterval = 5
  50.  
  51. currentTorch = 0
  52.  
  53. function tryTorch()
  54.     if currentTorch == torchInterval then
  55.         print("TORCH-PLACE")
  56.         torch = findItem("minecraft:torch")
  57.         if torch ~= nil then
  58.             turtle.select(torch)
  59.             turtle.digDown()
  60.             turtle.placeDown()
  61.         end
  62.     end
  63.     print("TORCHINT:", currentTorch)
  64.     currentTorch = (currentTorch + 1) % torchInterval + 1
  65. end
  66.  
  67. while true do
  68.  
  69.     print("TORCHINT:", currentTorch)
  70.  
  71.  
  72.     print("FUEL LEVEL--------", turtle.getFuelLevel())
  73.  
  74.     for i = 1, 16, 1 do
  75.         local data = turtle.getItemDetail(i)
  76.  
  77.         if data then
  78.             turtle.select(i)
  79.             turtle.refuel()
  80.             if table.contains(trash, data.name) then
  81.                 print("dropping:", data.name)
  82.                 turtle.select(i)
  83.                 turtle.drop()
  84.             end
  85.         end
  86.     end
  87.  
  88.     chestIndex = findItem("enderstorage:ender_storage")
  89.     if chestIndex ~= nil then
  90.  
  91.         turtle.select(chestIndex)
  92.         while not turtle.placeUp() do
  93.             turtle.digUp()
  94.         end
  95.  
  96.         for i = 1, 16, 1 do
  97.             local data = turtle.getItemDetail(i)
  98.  
  99.             if data then
  100.                 if not table.contains(donotStore, data.name) then
  101.                     turtle.select(i)
  102.                     turtle.dropUp()
  103.                 end
  104.             end
  105.         end
  106.         turtle.digUp()
  107.     end
  108.  
  109.  
  110.     while slotsLeft() < 2 do
  111.         print(slotsLeft())
  112.         print("TURTLE NEEDS EMPTYING!!!")
  113.         sleep(1)
  114.     end
  115.  
  116.     for i = 1, spacing + 1, 1 do
  117.         while not turtle.forward() do
  118.             turtle.dig()
  119.         end
  120.         while turtle.detectUp() do
  121.             turtle.digUp()
  122.         end
  123.         while turtle.detectDown() do
  124.             turtle.digDown()
  125.         end
  126.         tryTorch()
  127.     end
  128.  
  129.     turtle.turnLeft()
  130.  
  131.     for i = 1, branchLength, 1 do
  132.         print(tostring(i), "/", tostring(branchLength + 1), "Left")
  133.         while not turtle.forward() do
  134.             turtle.dig()
  135.         end
  136.  
  137.         while turtle.detectUp() do
  138.             turtle.digUp()
  139.         end
  140.         while turtle.detectDown() do
  141.             turtle.digDown()
  142.         end
  143.  
  144.  
  145.  
  146.     end
  147.  
  148.     turtle.turnLeft()
  149.     turtle.turnLeft()
  150.  
  151.     for i = 1, branchLength, 1 do
  152.         print(tostring(i), "/", tostring(branchLength * 2 + 1), "Left")
  153.         while not turtle.forward() do
  154.             turtle.dig()
  155.         end
  156.  
  157.         while turtle.detectUp() do
  158.             turtle.digUp()
  159.         end
  160.         while turtle.detectDown() do
  161.             turtle.digDown()
  162.         end
  163.         tryTorch()
  164.  
  165.  
  166.  
  167.     end
  168.  
  169.     for i = 1, branchLength, 1 do
  170.         print(tostring(i), "/", tostring(branchLength * 2 + 1), "Left")
  171.         while not turtle.forward() do
  172.             turtle.dig()
  173.         end
  174.  
  175.         while turtle.detectUp() do
  176.             turtle.digUp()
  177.         end
  178.         while turtle.detectDown() do
  179.             turtle.digDown()
  180.         end
  181.  
  182.  
  183.  
  184.     end
  185.  
  186.     turtle.turnLeft()
  187.     turtle.turnLeft()
  188.  
  189.     for i = 1, branchLength, 1 do
  190.         print(tostring(i), "/", tostring(branchLength + 1), "Left")
  191.         while not turtle.forward() do
  192.             turtle.dig()
  193.         end
  194.  
  195.  
  196.  
  197.         while turtle.detectUp() do
  198.             turtle.digUp()
  199.         end
  200.         while turtle.detectDown() do
  201.             turtle.digDown()
  202.         end
  203.         tryTorch()
  204.  
  205.     end
  206.     turtle.turnRight()
  207.  
  208.  
  209.  
  210. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement