feat: add parallel scanning and supply management configuration options
This commit is contained in:
@@ -46,6 +46,17 @@ C.COMPOST_HOPPER = "minecraft:hopper_0"
|
|||||||
-- Peripheral
|
-- Peripheral
|
||||||
C.PERIPHERAL_CACHE_TTL = 5
|
C.PERIPHERAL_CACHE_TTL = 5
|
||||||
|
|
||||||
|
-- Parallel scanning
|
||||||
|
C.PARALLEL_SCAN_CHUNKS = 8
|
||||||
|
|
||||||
|
-- Storage priority (higher = preferred; keyed by chest peripheral name)
|
||||||
|
C.CHEST_PRIORITY = {}
|
||||||
|
|
||||||
|
-- Builder / supply manifest
|
||||||
|
C.SUPPLY_CHEST = "" -- peripheral name of supply chest (empty = disabled)
|
||||||
|
C.SUPPLY_INTERVAL = 10 -- seconds between supply checks
|
||||||
|
C.SUPPLY_MANIFEST = {} -- { { name = "mod:item", count = N }, ... }
|
||||||
|
|
||||||
-- Furnace types
|
-- Furnace types
|
||||||
C.FURNACE_TYPES = {
|
C.FURNACE_TYPES = {
|
||||||
"minecraft:furnace",
|
"minecraft:furnace",
|
||||||
@@ -92,6 +103,11 @@ function C.loadConfig()
|
|||||||
if cfg.compostReserve then C.COMPOST_RESERVE = cfg.compostReserve end
|
if cfg.compostReserve then C.COMPOST_RESERVE = cfg.compostReserve end
|
||||||
if cfg.compostDropper then C.COMPOST_DROPPER = cfg.compostDropper end
|
if cfg.compostDropper then C.COMPOST_DROPPER = cfg.compostDropper end
|
||||||
if cfg.compostHopper then C.COMPOST_HOPPER = cfg.compostHopper end
|
if cfg.compostHopper then C.COMPOST_HOPPER = cfg.compostHopper end
|
||||||
|
if cfg.parallelScanChunks then C.PARALLEL_SCAN_CHUNKS = cfg.parallelScanChunks end
|
||||||
|
if cfg.chestPriority then C.CHEST_PRIORITY = cfg.chestPriority end
|
||||||
|
if cfg.supplyChest then C.SUPPLY_CHEST = cfg.supplyChest end
|
||||||
|
if cfg.supplyInterval then C.SUPPLY_INTERVAL = cfg.supplyInterval end
|
||||||
|
if cfg.supplyManifest then C.SUPPLY_MANIFEST = cfg.supplyManifest end
|
||||||
if cfg.logLevel then log.setLevel(cfg.logLevel) end
|
if cfg.logLevel then log.setLevel(cfg.logLevel) end
|
||||||
log.info("CONFIG", "Loaded from %s", CONFIG_FILE)
|
log.info("CONFIG", "Loaded from %s", CONFIG_FILE)
|
||||||
end
|
end
|
||||||
@@ -100,31 +116,36 @@ end
|
|||||||
-- Data tables
|
-- Data tables
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
C.SMELTABLE = dofile(_path("data/smeltable.lua"))
|
|
||||||
C.FUEL_LIST = dofile(_path("data/fuel.lua"))
|
C.FUEL_LIST = dofile(_path("data/fuel.lua"))
|
||||||
local _compostData = dofile(_path("data/compostable.lua"))
|
local _compostData = dofile(_path("data/compostable.lua"))
|
||||||
C.COMPOSTABLE = _compostData.items
|
C.COMPOSTABLE = _compostData.items
|
||||||
C.COMPOST_TRASH = _compostData.trash
|
C.COMPOST_TRASH = _compostData.trash
|
||||||
C.CRAFTABLE = dofile(_path("data/craftable.lua"))
|
|
||||||
C.LOW_STOCK_ALERTS = dofile(_path("data/alerts.lua"))
|
C.LOW_STOCK_ALERTS = dofile(_path("data/alerts.lua"))
|
||||||
|
|
||||||
-- Pre-build furnace compatibility sets for O(1) lookup
|
-- Recipe book: merges built-in recipes + user-learned recipes
|
||||||
for _, recipe in pairs(C.SMELTABLE) do
|
local recipeBook = dofile(_path("lib/recipeBook.lua"))
|
||||||
recipe.furnaceSet = {}
|
recipeBook.init(_path(".recipes.db"))
|
||||||
for _, ft in ipairs(recipe.furnaces) do
|
recipeBook.loadLegacyCrafting(dofile(_path("data/craftable.lua")))
|
||||||
recipe.furnaceSet[ft] = true
|
recipeBook.loadLegacySmelting(dofile(_path("data/smeltable.lua")))
|
||||||
end
|
C.recipeBook = recipeBook
|
||||||
end
|
C.SMELTABLE = recipeBook.getSmeltingTable()
|
||||||
|
C.CRAFTABLE = recipeBook.getCraftingList()
|
||||||
|
|
||||||
-- Pre-built smelt candidate lists per furnace type
|
-- Rebuild furnace/smelt indices from current recipe data
|
||||||
C.smeltCandidatesByType = {}
|
function C.rebuildIndices()
|
||||||
do
|
for _, recipe in pairs(C.SMELTABLE) do
|
||||||
|
recipe.furnaceSet = {}
|
||||||
|
for _, ft in ipairs(recipe.furnaces) do
|
||||||
|
recipe.furnaceSet[ft] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
C.smeltCandidatesByType = {}
|
||||||
for _, ftype in ipairs(C.FURNACE_TYPES) do
|
for _, ftype in ipairs(C.FURNACE_TYPES) do
|
||||||
C.smeltCandidatesByType[ftype] = {}
|
C.smeltCandidatesByType[ftype] = {}
|
||||||
end
|
end
|
||||||
for itemName, recipe in pairs(C.SMELTABLE) do
|
for itemName, recipe in pairs(C.SMELTABLE) do
|
||||||
local isFood = recipe.furnaceSet["minecraft:smoker"] or false
|
local isFood = recipe.furnaceSet["minecraft:smoker"] or false
|
||||||
for ft, _ in pairs(recipe.furnaceSet) do
|
for ft in pairs(recipe.furnaceSet) do
|
||||||
table.insert(C.smeltCandidatesByType[ft], { name = itemName, recipe = recipe, food = isFood })
|
table.insert(C.smeltCandidatesByType[ft], { name = itemName, recipe = recipe, food = isFood })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -136,6 +157,15 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Refresh recipes from recipeBook and rebuild all indices
|
||||||
|
function C.refreshRecipes()
|
||||||
|
C.SMELTABLE = C.recipeBook.getSmeltingTable()
|
||||||
|
C.CRAFTABLE = C.recipeBook.getCraftingList()
|
||||||
|
C.rebuildIndices()
|
||||||
|
end
|
||||||
|
|
||||||
|
C.rebuildIndices()
|
||||||
|
|
||||||
-- Build fuel set for quick lookup
|
-- Build fuel set for quick lookup
|
||||||
C.FUEL_SET = {}
|
C.FUEL_SET = {}
|
||||||
for _, f in ipairs(C.FUEL_LIST) do C.FUEL_SET[f.name] = true end
|
for _, f in ipairs(C.FUEL_LIST) do C.FUEL_SET[f.name] = true end
|
||||||
|
|||||||
Reference in New Issue
Block a user