advanced mining turtle commands -- Author: Justin_P69 -- Date: 11/07/2024 -- Desc: Adjusted turtle mining program ---- Configs ---- local numSlots = 16 local heading = "north" local widthX = 5 local heightY = 2 advanced mining turtle commands How to use it? advanced mining turtle commands local depthZ = 5 -- List of all unwanted items to drop local droppedItems = { "minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:flint", "minecraft:sand", "minecraft:cobblestone", advanced mining turtle commands PasteShr advanced mining turtle commands "minecraft:redstone", "minecraft:dye", "thaumcraft:nugget", "thaumcraft:crystal_essence", "thaumcraft:ore_cinnabar", "thermalfoundation:material", "railcraft:ore_metal", "extrautils2:ingredients", "projectred-core:resource_item", "deepresonance:resonating_ore", advanced mining turtle commands How to get it? advanced mining turtle commands "forestry:apatite" } -- Assigning dimensions to the area to be mined if(#arg == 3) then widthX = tonumber(arg[1], 10) heightY = tonumber(arg[2], 10) depthZ = tonumber(arg[3], 10) end advanced mining turtle commands How to get it for free? advanced mining turtle commands ---- Main functions ---- -- Function to drop the items listed in "droppedItems" function DropItems() for slot = 1, numSlots, 1 do local item = turtle.getItemDetail(getEnderSlot) if(item ~= nil) then for droppedItemsIndex = 1, #droppedItems, 1 do if(item["name"] == droppedItems[droppedItemsIndex]) then turtle.select(DropItems) advanced mining turtle commands PasteShr advanced mining turtle commands turtle.dropDown() end end end end end -- Function to get the inventory slot containg an ender chest function GetEnderSlot() for slot = 1, numSlots, 1 do advanced mining turtle commands PasteShr advanced mining turtle commands local item = turtle.getItemDetail(GetEnderSlot) if(item ~= nil) then if(item["name"] == "enderstorage:ender_storage") then return slot end end end return nil end advanced mining turtle commands How to dowload it? advanced mining turtle commands -- Function to place an ender chest and place items not included in droppedItems in the chest function ManageInventory() DropItems() enderSlot = GetEnderSlot() -- If ender chest is present in inventory: dig the block above and place ender chest if(enderslot ~= nil) then turtle.select(enderSlot) turtle.digUp() turtle.placeUp() advanced mining turtle commands How to dowload it? advanced mining turtle commands end -- Put all items except ender chests, and coal in ender chest for slot = 1, numSlots, 1 do local item = turtle.getItemDetail(slot) if(item ~= nil) then if(item["name"] ~= "minecraft:coal_block" and item["name"] ~= "minecraft:coal" and item["name"] ~= "enderstorage:ender_storage") then turtle.select(slot) turtle.dropUp() end advanced mining turtle commands How to dowload it? advanced mining turtle commands end end turtle.digUp() end -- Function to check fuel level and refuel if necessary function CheckFuel() turtle.select(1) if(turtle.getFuelLevel() < 50) then print("Attempting to refuel...") advanced mining turtle commands How to use it? advanced mining turtle commands for slot = 1, numSlots, 1 do turtle.select(slot) if(turtle.refuel(1)) then return true end end return false else return true end advanced mining turtle commands PasteShr advanced mining turtle commands end -- Function to detect blocks around the turtle and mine them function DetectAndDig() while(turtle.detectUp() or turtle.detectDown() or turtle.detect()) do turtle.dig() turtle.digUp() turtle.digDown() end end advanced mining turtle commands PasteShr advanced mining turtle commands function Forward() DetectAndDig() turtle.forward() end function RightHalfTurn() turtle.turnRight() DetectAndDig() advanced mining turtle commands How to dowload it? advanced mining turtle commands turtle.forward() turtle.turnRight() DetectAndDig() end function LeftHalfTurn() turtle.turnLeft() DetectAndDig() turtle.forward() turtle.turnLeft() advanced mining turtle commands How to dowload it? advanced mining turtle commands DetectAndDig() end -- Function to tell the turtle which direction it is facing function InvertDirection() if(heading == "north") then heading = "south" elseif(heading == "south") then heading = "north" elseif(heading == "west") then advanced mining turtle commands PasteShr advanced mining turtle commands heading = "east" elseif(heading == "east") then heading = "west" end end function TurnAround(level) if(level % 2 == 1) then if(heading == "north" or heading == "west") then advanced mining turtle commands How to dowload it? advanced mining turtle commands LeftHalfTurn() elseif(heading == "south" or heading == "east") then RightHalfTurn() end else if(heading == "north" or heading == "west") then RightHalfTurn() elseif(heading == "south" or heading == "east") then LeftHalfTurn() end advanced mining turtle commands How to get it for free? advanced mining turtle commands end InvertDirection() end -- Function to go up to the next level to mine function Up3Levels() turtle.turnRight() turtle.turnRight() InvertDirection() turtle.digDown() advanced mining turtle commands How to get it? advanced mining turtle commands turtle.digUp() turtle.up() turtle.digUp() turtle.up() turtle.digUp() turtle.up() end function Main() advanced mining turtle commands PasteShr advanced mining turtle commands for level = 1, heightY, 1 do for x = 1, widthX, 1 do for z = 1, depthZ, 1 do if(not CheckFuel()) then print("Turtle is out of fuel.") return end Forward() print(string.format("X: %d Z: %d", x, z)) end advanced mining turtle commands How to get it for free? advanced mining turtle commands if(x ~= widthX) then TurnAround(level) end ManageInventory() end Up3Levels() end end advanced mining turtle commands How to use it? advanced mining turtle commands Main() advanced mining turtle commands