Advertisement
DabDaddy6223

nether_miner

Apr 20th, 2025 (edited)
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. ACCEPTABLE_FUEL = {"minecraft:coal"}
  2. FUEL_COUNT = -1
  3. FUEL_INDEX = -1
  4.  
  5. -- Utilities
  6. function arrHasValue(arr, val)
  7.     for index, value in ipairs(arr) do
  8.         if value == val then
  9.             return true
  10.         end
  11.     end
  12.  
  13.     return false
  14. end
  15.  
  16. -- Fuel
  17. function hasFuel()
  18.     return FUEL_COUNT > 0
  19. end
  20.  
  21. function shouldRefuel()
  22.     return turtle.getFuelLevel() <= 0
  23. end
  24.  
  25. function refuel()
  26.     if shouldRefuel() == true then
  27.         if hasFuel() ~= true then
  28.             return false
  29.         end
  30.  
  31.         turtle.select(1)
  32.         turtle.refuel(1)
  33.         FUEL_COUNT = FUEL_COUNT - 1
  34.     end
  35.  
  36.     return true
  37. end
  38.  
  39. -- Inventory
  40. function getSlotData(index)
  41.     turtle.select(index)
  42.     local slotData = turtle.getItemDetail()
  43.     return slotData
  44. end
  45.  
  46.  
  47.  
  48. function main()
  49.     -- Setup
  50.     for i=1, 16 do
  51.         local curr_slot_data = getSlotData(i)
  52.         if curr_slot_data ~= nil then
  53.             if FUEL_INDEX == -1 then
  54.                 if arrHasValue(ACCEPTABLE_FUEL, curr_slot_data["name"]) then
  55.                     FUEL_INDEX = i
  56.                     FUEL_COUNT = curr_slot_data["count"]
  57.                     break
  58.                 end
  59.             end
  60.         end
  61.     end
  62.  
  63.     if FUEL_INDEX == -1 then
  64.         print("No fuel!")
  65.         return
  66.     end
  67.  
  68.     print("Fuel Index: " .. FUEL_INDEX)
  69.  
  70.     while true do
  71.         if refuel() == false then
  72.             print("Ran out of fuel!")
  73.             return
  74.         end
  75.  
  76.         local has_block, data = turtle.inspect()
  77.         if has_block then
  78.             if data["name"] == "minecraft:cobblestone" then
  79.                 break
  80.             end
  81.         end
  82.  
  83.         turtle.dig()
  84.         turtle.forward()
  85.         turtle.digUp()
  86.         turtle.digDown()
  87.     end
  88. end
  89.  
  90. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement