-- === CONFIG ===
local TARGET_COUNT = 63
local ORE_WHITELIST = {
["minecraft:raw_iron"] = true,
["minecraft:raw_copper"] = true,
["minecraft:raw_gold"] = true,
["silentgear:raw_azure_silver"] = true,
["allthemodium:raw_allthemodium"] = true,
["allthemodium:raw_vibranium"] = true,
["allthemodium:raw_unobtainium"] = true,
["alltheores:raw_tin"] = true,
["alltheores:raw_lead"] = true,
["alltheores:raw_silver"] = true,
["alltheores:raw_nickel"] = true,
["alltheores:raw_aluminum"] = true,
["alltheores:raw_platinum"] = true
}
local FUEL_NAME = "minecraft:coal"
-- positions of blocks (example coords, replace with yours!)
local LOCS = {
barrel = {x=772, y=86, z=-83, facing="north"},
chamber = {x=769, y=84, z=-83, facing="north"},
enderChest = {x=772, y=88, z=-83, facing="north"}
}
-- === POSITION TRACKING ===
local pos = {x=769, y=84, z=-82, facing="north"} -- starting point
-- you can set this with gps.locate() if GPS is available!
local function face(dir)
-- turn turtle until facing dir
local dirs = {"north","east","south","west"}
local idx = 1
for i,v in ipairs(dirs) do if v==pos.facing then idx=i end end
local target = 1
for i,v in ipairs(dirs) do if v==dir then target=i end end
local diff = (target - idx) % 4
if diff == 1 then turtle.turnRight()
elseif diff == 2 then turtle.turnRight(); turtle.turnRight()
elseif diff == 3 then turtle.turnLeft() end
pos.facing = dir
end
local function forward()
while not turtle.forward() do sleep(0.5) end
if pos.facing=="north" then pos.z=pos.z-1
elseif pos.facing=="south" then pos.z=pos.z+1
elseif pos.facing=="east" then pos.x=pos.x+1
elseif pos.facing=="west" then pos.x=pos.x-1 end
end
local function up() while not turtle.up() do sleep(0.5) end pos.y=pos.y+1 end
local function down() while not turtle.down() do sleep(0.5) end pos.y=pos.y-1 end
local function goTo(x,y,z)
-- very simple pathing: vertical first, then X, then Z
while pos.y < y do up() end
while pos.y > y do down() end
if pos.x < x then face("east"); while pos.x < x do forward() end
elseif pos.x > x then face("west"); while pos.x > x do forward() end end
if pos.z < z then face("south"); while pos.z < z do forward() end
elseif pos.z > z then face("north"); while pos.z > z do forward() end end
end
local function goToLoc(loc)
goTo(loc.x, loc.y, loc.z)
face(loc.facing)
end
-- === CHAMBER FUNCTIONS ===
local function countChamberItems()
goToLoc(LOCS.chamber)
local chamber = peripheral.wrap("front")
local input = chamber.getInputItem()
return input and input.count or 0
end
local function topUpChamber()
local current = countChamberItems()
if current >= TARGET_COUNT then return end
local need = TARGET_COUNT - current
-- fetch ore from barrel
goToLoc(LOCS.barrel)
for i=1,16 do
turtle.select(i)
turtle.suck(need)
local item = turtle.getItemDetail()
if item and ORE_WHITELIST[item.name] then
goToLoc(LOCS.chamber)
turtle.drop(item.count)
return
elseif item then
turtle.drop() -- dump non-ore back
end
end
end
-- === REFUEL ===
local function refuelIfNeeded()
if turtle.getFuelLevel() < 100 then
goToLoc(LOCS.enderChest)
for i=1,16 do
turtle.select(i)
turtle.suck(1)
local item = turtle.getItemDetail()
if item and item.name == FUEL_NAME then
turtle.refuel()
return
elseif item then
turtle.drop()
end
end
end
end
-- === MAIN LOOP ===
while true do
refuelIfNeeded()
topUpChamber()
sleep(5)
end