-- =======================
-- 9x9 QUARRY WITH ATM10 ORE FILTERING
-- Dynamic start Y using GPS
-- =======================
-- =======================
-- CONFIGURATION
-- =======================
local targetY = -53 -- change to your desired lowest layer
-- =======================
-- GET STARTING Y USING GPS
-- =======================
local function getCurrentY()
local x, y, z = gps.locate(5) -- 5 second timeout
if y then
return y
else
error("GPS not found. Make sure a GPS network is set up!")
end
end
local currentY = getCurrentY()
print("Starting Y detected via GPS: " .. currentY)
-- =======================
-- SAFE MOVEMENT FUNCTIONS
-- =======================
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
-- =======================
-- MINE 9x9 LAYER
-- =======================
local function mine9x9()
local turnRight = true
for row = 1, 9 do
for col = 1, 8 do
turtle.dig()
forward()
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
turtle.turnLeft()
turtle.turnLeft()
for i = 1, 8 do forward() end
turtle.turnRight()
for i = 1, 8 do forward() end
turtle.turnRight()
end
-- =======================
-- ATM10 VALUABLES SETUP
-- =======================
local valuables = {
-- Vanilla ores
["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
["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,
}
local function isValuable(slot)
local detail = turtle.getItemDetail(slot)
return detail and valuables[detail.name]
end
local function isInventoryFull()
for slot = 1, 16 do
if turtle.getItemCount(slot) == 0 then
return false
end
end
return true
end
local function storeValuables()
-- Turn 180° to face chest
local ok1, ok2 = turtle.turnLeft(), turtle.turnLeft()
if not (ok1 and ok2) then
print("ERROR: Cannot turn to chest. Check surroundings!")
return
end
for slot = 1, 16 do
if isValuable(slot) then
turtle.select(slot)
local success = turtle.drop() -- drops downward by default
if not success then
print("Warning: Could not drop items from slot " .. slot)
end
end
end
-- Turn back to mining direction
turtle.turnLeft()
turtle.turnLeft()
end
-- =======================
-- MAIN LOOP
-- =======================
while currentY > targetY do
mine9x9()
print("Layer mined at Y = " .. currentY)
if isInventoryFull() then
print("Inventory full — storing valuables in chest behind start.")
storeValuables()
end
if currentY == targetY then
print("Reached target Y. Stopping.")
break
end
down()
currentY = currentY - 1
end
-- Final deposit of any remaining valuables
storeValuables()
print("Finished at Y = " .. currentY)