Advertisement
a_alien

digi.lua

Apr 27th, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.93 KB | None | 0 0
  1. local pos = 0
  2. local fuel = "minecraft:lava_bucket"
  3. local fuelContainer = "enderstorage:ender_chest"
  4. local keep = {
  5.     [fuel] = true,
  6.     ["minecraft:ancient_debris"] = true,
  7.     ["tconstruct:cobalt_ore"] = true,
  8.     ["minecraft:cobblestone"] = true
  9. }
  10. local badFluid = "minecraft:lava"
  11. local dir = 1
  12. local length = 30
  13.  
  14. local turtle = turtle -- This line is just becus i use VS code and its is complaning on all lines that containins "turtle" so i make this vriabel you can remove it or keep it do as you whant
  15.  
  16. local function refuel()
  17.     for i = 1, 16 do -- for each slot in the chest
  18.         local item = turtle.getItemDetail(i, false)
  19.         if item then -- if there is an item in this slot
  20.             if string.format("%s", item.name) == fuelContainer then -- if the item is in the blacklist
  21.                 turtle.select(i)
  22.                 break;
  23.             end
  24.         end
  25.     end
  26.     turtle.placeUp()
  27.     if(turtle.detectUp()) then
  28.         local chest = peripheral.find("chest")
  29.         local list = chest.list()
  30.  
  31.         for i = 1, chest.size() do -- for each slot in the chest
  32.         local item = list[i]
  33.             if item then -- if there is an item in this slot
  34.                 if not blacklist[string.format("%s:%s", item.name, item.metadata)] then -- if the item is NOT in the blacklist
  35.                 -- do something with the item.
  36.                 end
  37.             end
  38.         end
  39.     else
  40.         error("did not found the enderchest above shuting down")
  41.     end
  42. end
  43.  
  44. local function checkInv()
  45.     for i = 1, 16 do -- for each slot in the chest
  46.         local item = turtle.getItemDetail(i, false)
  47.         if item then -- if there is an item in this slot
  48.             if not keep[string.format("%s", item.name)] then -- if the item is in the blacklist
  49.                 turtle.select(i)
  50.                 turtle.drop()
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56. local function select()
  57.     for i = 1, 16 do -- for each slot in the chest
  58.         local item = turtle.getItemDetail(i, false)
  59.         if item then -- if there is an item in this slot
  60.             if not keep[string.format("%s", item.name)] then -- if the item is NOT in the blacklist
  61.                 turtle.select(i)
  62.             end
  63.         end
  64.     end
  65. end
  66.  
  67. local function lava()
  68.     local isBlock,block = turtle.inspectUp()
  69.     if isBlock then
  70.         if block.name == badFluid then
  71.             turtle.up()
  72.             isBlock,block = turtle.inspectUp()
  73.             if isBlock then
  74.                 if block.name == badFluid then
  75.                     select()
  76.                     turtle.placeUp()
  77.                 end
  78.             end
  79.             turtle.down()
  80.         end
  81.     end
  82.     isBlock,block = turtle.inspectDown()
  83.     if isBlock then
  84.         if block.name == badFluid then
  85.             turtle.down()
  86.             isBlock,block = turtle.inspectDown()
  87.             if isBlock then
  88.                 if block.name == badFluid then
  89.                     select()
  90.                     turtle.placeDown()
  91.                 end
  92.             end
  93.             turtle.up()
  94.         end
  95.     end
  96. end
  97.  
  98. local function loop()
  99.     local ready = true
  100.  
  101.     lava()
  102.  
  103.     while ready do
  104.         while turtle.detect() do
  105.             turtle.dig()
  106.             print("block in front")
  107.         end
  108.         while turtle.detectUp() do
  109.             turtle.digUp()
  110.             print("block on top")
  111.         end
  112.         while turtle.detectDown() do
  113.             turtle.digDown()
  114.             print("block on botem")
  115.         end
  116.        
  117.         if not turtle.detect() then
  118.             ready = false
  119.         end
  120.     end
  121.     lava()
  122.     turtle.forward()
  123. end
  124.  
  125. while true do
  126.    
  127.     if(pos == length) then
  128.         pos = -1
  129.     end
  130.    
  131.     refuel()
  132.  
  133.     loop()
  134.    
  135.     if(pos == -1) then
  136.        
  137.         if(dir == 1) then
  138.             turtle.turnRight()
  139.             dir = 0
  140.             loop()
  141.             turtle.turnRight()
  142.         else
  143.             turtle.turnLeft()
  144.             dir = 1
  145.             loop()
  146.             turtle.turnLeft()
  147.         end
  148.         checkInv()
  149.     end
  150.     pos = pos +1
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement