Advertisement
a_alien

digi.lua

Apr 27th, 2021
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.33 KB | None | 0 0
  1. local pos = 0
  2.  
  3. local keep = {
  4.     ["minecraft:coal"] = true,
  5.     ["minecraft:ancient_debris"] = true,
  6.     ["tconstruct:cobalt_ore"] = true,
  7.     ["minecraft:cobblestone"] = true
  8. }
  9.  
  10.  
  11.  
  12. local badFluid = "minecraft:lava"
  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 dir = 1
  17.  
  18. local function fule()
  19.     for i = 1, 16 do -- for each slot in the chest
  20.         local item = turtle.getItemDetail(i, false)
  21.         if item then -- if there is an item in this slot
  22.             if (string.format("%s", item.name) == "minecraft:coal") then -- if the item is in the blacklist
  23.                 turtle.select(i)
  24.             end
  25.         end
  26.     end
  27.     while(turtle.getFuelLevel() < 160) do
  28.         turtle.refuel(1)
  29.     end
  30. end
  31.  
  32. local function checkInv()
  33.     for i = 1, 16 do -- for each slot in the chest
  34.         local item = turtle.getItemDetail(i, false)
  35.         if item then -- if there is an item in this slot
  36.             if not keep[string.format("%s", item.name)] then -- if the item is in the blacklist
  37.                 turtle.select(i)
  38.                 turtle.drop()
  39.             end
  40.         end
  41.     end
  42. end
  43.  
  44. local function select()
  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 NOT in the blacklist
  49.                 turtle.select(i)
  50.             end
  51.         end
  52.     end
  53. end
  54.  
  55. local function lava()
  56.     local isBlock,block = turtle.inspectUp()
  57.     if isBlock then
  58.         if block.name == "minecraft:lava" then
  59.             turtle.up()
  60.             isBlock,block = turtle.inspectUp()
  61.             if isBlock then
  62.                 if block.name == "minecraft:lava" then
  63.                     select()
  64.                     turtle.placeUp()
  65.                 end
  66.             end
  67.             turtle.down()
  68.         end
  69.     end
  70.     isBlock,block = turtle.inspectDown()
  71.     if isBlock then
  72.         if block.name == "minecraft:lava" then
  73.             turtle.down()
  74.             isBlock,block = turtle.inspectDown()
  75.             if isBlock then
  76.                 if block.name == "minecraft:lava" then
  77.                     select()
  78.                     turtle.placeDown()
  79.                 end
  80.             end
  81.             turtle.up()
  82.         end
  83.     end
  84. end
  85.  
  86. local function loop()
  87.     local ready = true
  88.  
  89.     lava()
  90.  
  91.     while ready do
  92.         while turtle.detect() do
  93.             turtle.dig()
  94.             print("block in front")
  95.         end
  96.         while turtle.detectUp() do
  97.             turtle.digUp()
  98.             print("block on top")
  99.         end
  100.         while turtle.detectDown() do
  101.             turtle.digDown()
  102.             print("block on botem")
  103.         end
  104.        
  105.         if not turtle.detect() then
  106.             ready = false
  107.         end
  108.     end
  109.     lava()
  110.     turtle.forward()
  111. end
  112.  
  113. while true do
  114.    
  115.     if(pos == 30) then
  116.         pos = -1
  117.     end
  118.    
  119.     fule()
  120.  
  121.     loop()
  122.    
  123.     if(pos == -1) then
  124.         checkInv()
  125.         if(dir == 1) then
  126.             turtle.turnRight()
  127.             dir = 0
  128.             loop()
  129.             turtle.turnRight()
  130.         else
  131.             turtle.turnLeft()
  132.             dir = 1
  133.             loop()
  134.             turtle.turnLeft()
  135.         end
  136.     end
  137.     pos = pos +1
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement