feat(ui): 'Lager til' viser kun bygninger der kan tage flowets lagervarer (paller -> palleskure der tager varen); valgt palleskur bruges til palleture (v1.19.2.0)

This commit is contained in:
2026-09-24 19:40:35 +02:00
parent a2444661a0
commit 2ed79cf461
7 changed files with 113 additions and 9 deletions
+58
View File
@@ -147,6 +147,64 @@ function ADRunsController.getPickupMarkers()
return result
end
-- Varer flowet kører til lager (politik Lager / Salg, ellers lager): {{fillType, isPallet}}.
-- Er ingen vare sat til lager endnu, alle kildernes varer (så listen ikke er tom mens man opsætter).
function ADRunsController.getStoreGoods(adEnv, run)
local products = ADRunsController.getRunProducts(adEnv, run)
local goods = {}
for _, product in ipairs(products) do
if product.policy == "store" or product.policy == "sellElseStore" then
table.insert(goods, {fillType = product.fillType, isPallet = product.isPallet == true})
end
end
if #goods == 0 then
for _, product in ipairs(products) do
table.insert(goods, {fillType = product.fillType, isPallet = product.isPallet == true})
end
end
return goods
end
-- Kan bygningen tage mindst én af varerne som lager? Palleskur: pallevarer det tager. Silo/egen fabrik:
-- bulkvarer dens aflæsningsstation tager (samme regel som lagerturene: ADLoadSwap.isStoreTarget).
function ADRunsController.canStoreAt(adEnv, building, goods)
if building.kind == "objectStorage" then
for _, good in ipairs(goods or {}) do
if good.isPallet and ADSources ~= nil and ADSources.objectStorageAccepts ~= nil and ADSources.objectStorageAccepts(building.placeable, good.fillType) then
return true
end
end
return false
end
if building.unloadMarker == nil or ADLoadSwap == nil or ADLoadSwap.isStoreTarget == nil then
return false
end
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or 1
local station = ADSmartPickup.getUnloadStationAtWayPointId(adEnv, building.unloadMarker.id, farmId)
if station == nil then
return false
end
for _, good in ipairs(goods or {}) do
if not good.isPallet and ADLoadSwap.isStoreTarget(station, good.fillType, nil, true)
and (station.getIsFillTypeSupported == nil or station:getIsFillTypeSupported(good.fillType)) then
return true
end
end
return false
end
-- "Lager til"-bygningerne selv (i valgt rækkefølge) — til palleture der skal til et bestemt palleskur.
function ADRunsController.getStoreBuildings(adEnv, run)
local result = {}
if ADBuildings == nil or run == nil then return result end
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or 1
for _, buildingId in ipairs(run.storeBuildingIds or {}) do
local building = ADBuildings.find(adEnv, farmId, buildingId)
if building ~= nil then table.insert(result, building) end
end
return result
end
-- "Lager til": aflæsningsmarkører for flowets valgte lagerbygninger, i valgt rækkefølge (tom = ingen tvang).
function ADRunsController.getStoreMarkers(adEnv, run)
local result = {}