feat: kæder respekterer fabrikkens udgang (Fordel = intet flow, Sælg på mellemvare -> Behold)
This commit is contained in:
@@ -92,6 +92,28 @@ end
|
||||
-- ---- læsning pr. del ----
|
||||
|
||||
-- En fabriks produktioner -> opskrifter + punkter (samles først, så en fejl midtvejs ikke efterlader halve).
|
||||
-- Udgangens fordeling (spillets Sælg/Fordel/Behold) -> "sell"|"distribute"|"keep". Behold dækker både spawn (paller
|
||||
-- ved fabrikken) og lager (STORE fra ProductionStorageControl): begge dele skal hentes af et flow.
|
||||
function ADChainData.outputModeName(mode)
|
||||
local modes = ProductionPoint ~= nil and ProductionPoint.OUTPUT_MODE or {}
|
||||
if mode ~= nil and mode == modes.DIRECT_SELL then return "sell" end
|
||||
if mode ~= nil and mode == modes.AUTO_DELIVER then return "distribute" end
|
||||
return "keep"
|
||||
end
|
||||
|
||||
local function outputModes(point, outputs, nameOf)
|
||||
local modes = {}
|
||||
if point.getOutputDistributionMode == nil then return modes end
|
||||
for _, output in ipairs(outputs or {}) do
|
||||
local name = output.type ~= nil and nameOf(output.type) or nil
|
||||
if name ~= nil then
|
||||
local ok, mode = pcall(point.getOutputDistributionMode, point, output.type)
|
||||
modes[name] = ADChainData.outputModeName(ok and mode or nil)
|
||||
end
|
||||
end
|
||||
return modes
|
||||
end
|
||||
|
||||
local function readFactory(placeable, point, byChain, nameOf)
|
||||
local uid = placeableId(placeable)
|
||||
if uid == nil then return {}, {} end
|
||||
@@ -102,8 +124,9 @@ local function readFactory(placeable, point, byChain, nameOf)
|
||||
table.insert(recipes, {key = key, name = tostring(production.name or production.id), building = uid,
|
||||
buildingName = buildingName, enabled = isEnabled(point, production), byChain = (byChain or {})[key] == true,
|
||||
cyclesPerMonth = ADChainData.cyclesPerMonth(production),
|
||||
inputs = amountsByName(production.inputs, nameOf), outputs = amountsByName(production.outputs, nameOf)})
|
||||
points[key] = {point = point, productionId = production.id, placeable = placeable}
|
||||
inputs = amountsByName(production.inputs, nameOf), outputs = amountsByName(production.outputs, nameOf),
|
||||
outputModes = outputModes(point, production.outputs, nameOf)})
|
||||
points[key] = {point = point, productionId = production.id, placeable = placeable, buildingName = buildingName}
|
||||
end
|
||||
return recipes, points
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user