fix: læs lager direkte fra produktionspunktet når targetStorages mangler (v1.1.0.0)

Genskabt efter disk-crash 2026-09-21: det oprindelige commit (d38366e) gik tabt
som tomt objekt; indholdet er gendannet fra arbejdskopien. README udvidet med
behovsstyret forsyning, test S10 dækker produktionspunkt-lageret.
This commit is contained in:
2026-09-21 15:18:02 +02:00
parent fb87dc4d37
commit 95615253b0
4 changed files with 59 additions and 8 deletions
+15 -1
View File
@@ -186,13 +186,27 @@ function ADSmartPickup.findLeastFilledPickup(adEnv, driver)
return findLeastFilled(collectMarkerStations(adEnv, groupMarkers, farmId, nil), fillTypes, farmId)
end
-- Lagrene bag aflæsningsstationen; produktionspunkter uden targetStorages læses direkte.
local function getTargetStorages(station)
if station.targetStorages ~= nil and next(station.targetStorages) ~= nil then
return station.targetStorages
end
local placeable = station.owningPlaceable
local productionPoint = placeable ~= nil and placeable.spec_productionPoint ~= nil and placeable.spec_productionPoint.productionPoint or nil
if productionPoint ~= nil and productionPoint.storage ~= nil then
return {productionPoint.storage}
end
return {}
end
-- Niveau + kapacitet pr. ingrediens i aflæsningsmålets lager.
local function getTargetNeeds(station, ingredients, farmId)
local needs = {}
local storages = getTargetStorages(station)
for _, fillType in ipairs(ingredients) do
if station.getIsFillTypeSupported == nil or station:getIsFillTypeSupported(fillType) then
local level, freeSpace = 0, 0
for _, storage in pairs(station.targetStorages or {}) do
for _, storage in pairs(storages) do
level = level + (storage:getFillLevel(fillType) or 0)
freeSpace = freeSpace + (storage:getFreeCapacity(fillType) or 0)
end