Advertisement
a_alien

digi.lua

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