Advertisement
psicubed

Untitled

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