better support for mass furnaces
This commit is contained in:
@@ -100,44 +100,46 @@ local function process(list)
|
|||||||
active = false
|
active = false
|
||||||
|
|
||||||
for _, furnace in ipairs(Util.shallowCopy(furni)) do
|
for _, furnace in ipairs(Util.shallowCopy(furni)) do
|
||||||
local f = furnace.list()
|
pcall(function()
|
||||||
|
local f = furnace.list()
|
||||||
|
|
||||||
-- items to cook
|
-- items to cook
|
||||||
local item = list[INPUT_SLOT]
|
local item = list[INPUT_SLOT]
|
||||||
local cooking = f[INPUT_SLOT]
|
local cooking = f[INPUT_SLOT]
|
||||||
|
|
||||||
if cooking or item then
|
if cooking or item then
|
||||||
active = true
|
active = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if item and item.count > 0 then
|
if item and item.count > 0 then
|
||||||
if not cooking then -- or cooking.name == item.name then
|
if not cooking or cooking.name == item.name then
|
||||||
local count = cooking and cooking.count or 0
|
local count = cooking and cooking.count or 0
|
||||||
if count < 64 then
|
if count < 64 then
|
||||||
print('cooking : ' .. furnace.name)
|
print('cooking : ' .. furnace.name)
|
||||||
count = furnace.pullItems(localName, INPUT_SLOT, SMELT_AMOUNT, INPUT_SLOT)
|
count = furnace.pullItems(localName, INPUT_SLOT, SMELT_AMOUNT, INPUT_SLOT)
|
||||||
item.count = item.count - count
|
item.count = item.count - count
|
||||||
Util.removeByValue(furni, furnace)
|
Util.removeByValue(furni, furnace)
|
||||||
table.insert(furni, furnace)
|
table.insert(furni, furnace)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- fuel
|
-- fuel
|
||||||
local fuel = f[FUEL_SLOT] or { count = 0 }
|
local fuel = f[FUEL_SLOT] or { count = 0 }
|
||||||
if fuel.count < 8 then
|
if fuel.count < 8 then
|
||||||
print('fueling ' ..furnace.name)
|
print('fueling ' ..furnace.name)
|
||||||
furnace.pullItems(localName, FUEL_SLOT, 8 - fuel.count, FUEL_SLOT)
|
furnace.pullItems(localName, FUEL_SLOT, 8 - fuel.count, FUEL_SLOT)
|
||||||
end
|
|
||||||
|
|
||||||
local result = f[OUTPUT_SLOT]
|
|
||||||
if result then
|
|
||||||
if not list[OUTPUT_SLOT] or result.name == list[OUTPUT_SLOT].name then
|
|
||||||
print('pulling from : ' .. furnace.name)
|
|
||||||
furnace.pushItems(localName, OUTPUT_SLOT, result.count, OUTPUT_SLOT)
|
|
||||||
list[OUTPUT_SLOT] = result
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
local result = f[OUTPUT_SLOT]
|
||||||
|
if result then
|
||||||
|
if not list[OUTPUT_SLOT] or result.name == list[OUTPUT_SLOT].name then
|
||||||
|
print('pulling from : ' .. furnace.name)
|
||||||
|
furnace.pushItems(localName, OUTPUT_SLOT, result.count, OUTPUT_SLOT)
|
||||||
|
list[OUTPUT_SLOT] = result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return active
|
return active
|
||||||
|
|||||||
Reference in New Issue
Block a user