Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function findFuel()
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- if itemDetails.name == "minecraft:coal" then
- turtle.refuel()
- break
- end
- end
- end
- turtle.select(1)
- end
- local function findAndPlaceTorch()
- if counter ~= 6 then
- counter = counter + 1
- return
- end
- counter = 1
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- if itemDetails.name == "minecraft:torch" then
- turtle.placeDown()
- break
- end
- end
- end
- turtle.select(1)
- end
- local function cleanInventory()
- local blocksToClean = {
- "minecraft:cobblestone",
- "minecraft:deepslate",
- "minecraft:cobbled_deepslate",
- "minecraft:granite",
- "minecraft:diorite",
- "minecraft:gravel",
- "minecraft:dirt",
- "indreb:uranium_ore",
- "mekanism:uranium_ore",
- "minecraft:calcite",
- "minecraft:amethyst_block",
- "minecraft:tuff"
- }
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- for i=1,#blocksToClean do
- if itemDetails.name == blocksToClean[i] then
- turtle.dropDown()
- break
- end
- end
- end
- end
- turtle.select(1)
- end
- local useTorches = false
- counter = 1
- term.clear()
- term.setCursorPos(1, 1)
- print("Do I need to place torches?[y/n]")
- local input = io.read()
- if input == "y" then
- useTorches = true
- end
- while true do
- --Fuel logic
- while turtle.getFuelLevel() == 0 do
- findFuel()
- end
- if turtle.getFuelLevel() <= 10 then
- findFuel()
- end
- --Fuel main digging and torch if specified
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- if useTorches then
- findAndPlaceTorch()
- end
- --Fuel ouput
- term.clear()
- term.setCursorPos(1, 1)
- print("Fuel level: " .. turtle.getFuelLevel())
- --Cleaing inventory logic
- cleanInventory()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement