Enhance auto-smelting function to check for incompatible items in input slot and remove them
This commit is contained in:
@@ -772,7 +772,37 @@ local function autoSmelt()
|
|||||||
-- Re-read after output pull
|
-- Re-read after output pull
|
||||||
contents = furnace.list()
|
contents = furnace.list()
|
||||||
|
|
||||||
-- 2) Refuel if fuel slot is empty or low
|
-- 2) Check for incompatible items in input slot and remove them
|
||||||
|
local furnaceType = peripheral.getType(fname)
|
||||||
|
local inputItem = contents[SLOT_INPUT]
|
||||||
|
if inputItem then
|
||||||
|
local recipe = SMELTABLE[inputItem.name]
|
||||||
|
local validHere = false
|
||||||
|
if recipe then
|
||||||
|
for _, ft in ipairs(recipe.furnaces) do
|
||||||
|
if ft == furnaceType then
|
||||||
|
validHere = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not validHere then
|
||||||
|
-- This item doesn't belong in this furnace type — pull it out
|
||||||
|
for _, chest in ipairs(chests) do
|
||||||
|
local n = furnace.pushItems(chest, SLOT_INPUT)
|
||||||
|
if n and n > 0 then
|
||||||
|
print(string.format("[SMELT] Removed incompatible %s x%d from %s -> %s",
|
||||||
|
inputItem.name, n, fname, chest))
|
||||||
|
didWork = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Re-read after removal
|
||||||
|
contents = furnace.list()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 3) Refuel if fuel slot is empty or low
|
||||||
local fuelItem = contents[SLOT_FUEL]
|
local fuelItem = contents[SLOT_FUEL]
|
||||||
local needFuel = not fuelItem or fuelItem.count < 8
|
local needFuel = not fuelItem or fuelItem.count < 8
|
||||||
|
|
||||||
@@ -803,9 +833,8 @@ local function autoSmelt()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 3) Load smeltable items into empty input slot
|
-- 4) Load smeltable items into empty input slot
|
||||||
local inputItem = contents[SLOT_INPUT]
|
inputItem = contents[SLOT_INPUT]
|
||||||
local furnaceType = peripheral.getType(fname)
|
|
||||||
if not inputItem then
|
if not inputItem then
|
||||||
-- Find something smeltable in chests that this furnace type can process
|
-- Find something smeltable in chests that this furnace type can process
|
||||||
for itemName, recipe in pairs(SMELTABLE) do
|
for itemName, recipe in pairs(SMELTABLE) do
|
||||||
|
|||||||
Reference in New Issue
Block a user