-- quarry_basic.lua
-- Simple 9x9 quarry (no GPS). Chest must be directly behind the starting tile.
-- Mines exact 9x9 coverage, drops trash down, deposits valuables behind, refuels from coal.
-- Mines down to Y = -53.
local TARGET_Y = -53
-- Simple lists
local trash = {
["minecraft:cobblestone"] = true,
["minecraft:dirt"] = true,
["minecraft:gravel"] = true,
["minecraft:sand"] = true,
["minecraft:netherrack"] = true,
}
local valuables = {
["minecraft:diamond"] = true,
["minecraft:iron_ore"] = true,
["minecraft:gold_ore"] = true,
["minecraft:coal"] = true,
["minecraft:redstone"] = true,
["minecraft:lapis_lazuli"] = true,
["minecraft:emerald"] = true,
-- ATM10 ores (add any missing ones you want)
["alltheores:allthemodium_ore"] = true,
["alltheores:vibranium_ore"] = true,
["alltheores:unobtainium_ore"] = true,
["alltheores:aluminum_ore"] = true,
["alltheores:antimony_ore"] = true,
["alltheores:arcane_crystal_ore"] = true,
["alltheores:black_quartz_ore"] = true,
["alltheores:copper_ore"] = true,
["alltheores:lead_ore"] = true,
["alltheores:nickel_ore"] = true,
["alltheores:osmium_ore"] = true,
["alltheores:platinum_ore"] = true,
["alltheores:peridot_ore"] = true,
["alltheores:prosperity_ore"] = true,
["alltheores:runic_ore"] = true,
["alltheores:ruby_ore"] = true,
["alltheores:sapphire_ore"] = true,
["alltheores:silver_ore"] = true,
["alltheores:tin_ore"] = true,
["alltheores:tungsten_ore"] = true,
["alltheores:uranium_ore"] = true,
["alltheores:uraninite_ore"] = true,
["alltheores:zinc_ore"] = true,
["alltheores:xychorium_blue_ore"] = true,
["alltheores:xychorium_dark_ore"] = true,
["alltheores:xychorium_green_ore"] = true,
["alltheores:xychorium_light_ore"] = true,
["alltheores:xychorium_red_ore"] = true,
}
-- Utilities
local function forward()
while not turtle.forward() do
turtle.dig()
sleep(0.1)
end
end
local function down()
while not turtle.down() do
turtle.digDown()
sleep(0.1)
end
end
local function up()
while not turtle.up() do
turtle.digUp()
sleep(0.1)
end
end
local function countFree()
local n = 0
for s=1,16 do if turtle.getItemCount(s) == 0 then n = n + 1 end end
return n
end
local function findCoal()
for s=1,16 do
local d = turtle.getItemDetail(s)
if d and (d.name == "minecraft:coal" or d.name == "minecraft:charcoal") then
return s
end
end
return nil
end
local function refuelIfNeeded()
local lvl = turtle.getFuelLevel()
if lvl == "unlimited" then return true end
if type(lvl) == "number" and lvl > 20 then return true end
local s = findCoal()
if s then
turtle.select(s)
turtle.refuel(1)
return true
end
return false
end
local function isTrashSlot(s)
local d = turtle.getItemDetail(s)
if not d then return false end
return trash[d.name] == true
end
local function isValuableSlot(s)
local d = turtle.getItemDetail(s)
if not d then return false end
return valuables[d.name] == true
end
local function dropTrashDown()
for s=1,16 do
if isTrashSlot(s) then
turtle.select(s)
turtle.dropDown()
end
end
end
local function depositValuablesBehind()
-- face chest behind (turn 180), drop valuables, return facing original direction
turtle.turnLeft(); turtle.turnLeft()
for s=1,16 do
if isValuableSlot(s) then
turtle.select(s)
turtle.drop()
end
end
turtle.turnLeft(); turtle.turnLeft()
end
local function chestBehindPresent()
turtle.turnLeft(); turtle.turnLeft()
local ok, data = turtle.inspect()
turtle.turnLeft(); turtle.turnLeft()
if ok and data and (string.find(data.name or "", "chest") or string.find(data.name or "", "barrel")) then
return true
end
return false
end
-- 9x9 miner (bottom-left corner start, facing INTO grid)
local function mine9x9()
local turnRight = true
for row = 1, 9 do
for col = 1, 9 do
-- fuel and dig only the required faces
refuelIfNeeded()
pcall(turtle.digUp)
turtle.dig() -- clear the block in front (this is the cell)
pcall(turtle.digDown)
if col < 9 then
forward()
pcall(turtle.digDown)
end
-- if inventory low, drop trash now
if countFree() <= 2 then
dropTrashDown()
if countFree() == 0 then
if chestBehindPresent() then depositValuablesBehind() end
end
end
end
if row < 9 then
if turnRight then
turtle.turnRight()
turtle.dig()
forward()
turtle.turnRight()
else
turtle.turnLeft()
turtle.dig()
forward()
turtle.turnLeft()
end
turnRight = not turnRight
end
end
-- return to starting corner and facing
turtle.turnLeft(); turtle.turnLeft()
for i=1,8 do forward() end
turtle.turnRight()
for i=1,8 do forward() end
turtle.turnRight()
end
-- MAIN
print("Enter starting absolute Y (example: 64):")
local currentY = tonumber(read())
if not currentY then
error("Invalid starting Y.")
end
if currentY <= TARGET_Y then
error("Starting Y must be above "..TARGET_Y)
end
if not chestBehindPresent() then
print("Warning: chest not detected behind start. Place a chest directly behind turtle.")
end
while currentY > TARGET_Y do
mine9x9()
dropTrashDown()
if countFree() == 0 then
if chestBehindPresent() then
depositValuablesBehind()
else
error("Inventory full and no chest behind. Manual intervention required.")
end
end
down()
currentY = currentY - 1
end
-- final deposit
if chestBehindPresent() then depositValuablesBehind() end
print("Quarry finished at Y = "..currentY)