feat(kilder): generelt lager — bygninger med egen læssestation uden silo/fabrik/stald-spec (P&H separatorhal, digestat) kan vælges under Fra; varer fra stationen (v1.18.4.0)

This commit is contained in:
2026-09-24 13:54:45 +02:00
parent 925163758a
commit fe3a4284c5
9 changed files with 72 additions and 3 deletions
+30
View File
@@ -141,6 +141,10 @@ function ADSources.identify(adEnv, wayPointId, farmId)
if placeable ~= nil and placeable.getHusbandryFillLevel ~= nil then
return {kind = "husbandry", placeable = placeable, station = station, wayPointId = wayPointId, name = getPlaceableName(placeable, markerName)}
end
-- generelt lager: anden bygning med læssestation (fx separatorhal med digestat); varer fra stationen
if placeable ~= nil and placeable.spec_objectStorage == nil then
return {kind = "storage", placeable = placeable, station = station, wayPointId = wayPointId, name = getPlaceableName(placeable, markerName)}
end
-- Det strenge opslag (trigger bag næsen) passer til silorækker; en mælketank eller fabrik ligger
-- ofte ved siden af markøren. Løst opslag inden for 40 m — men aldrig for siloer.
if placeable == nil and ADSmartPickup.getLoadStationNearWayPointId ~= nil then
@@ -402,6 +406,30 @@ local function getHusbandryProducts(adEnv, source)
return products
end
-- Generelt lager: det læssestationen har af de varer den udleverer (supportedFillTypes/triggeres fillTypes;
-- ukendt = alt med niveau). Kapacitet = stationens samlede.
local function getStationProducts(source)
local station = source.station
if station == nil or station.getAllFillLevels == nil then
return {}
end
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or 1
local ok, levels, capacity = pcall(station.getAllFillLevels, station, farmId)
if not ok or type(levels) ~= "table" then
return {}
end
local supported = station.supportedFillTypes
local products = {}
for fillType, level in pairs(levels) do
local isSupported = supported == nil or next(supported) == nil or supported[fillType] == true
if isSupported and (level or 0) > 0 then
table.insert(products, newProduct(fillType, level, level, math.max(tonumber(capacity) or 0, level), false))
end
end
table.sort(products, function(a, b) return a.fillType < b.fillType end)
return products
end
-- Varer ved kilden med tilgængelig mængde: { {fillType, name, title, available, level, capacity, isPallet} }.
function ADSources.getProducts(adEnv, source, farmId)
if source.kind == "factory" then
@@ -410,6 +438,8 @@ function ADSources.getProducts(adEnv, source, farmId)
return getSiloProducts(source)
elseif source.kind == "husbandry" then
return getHusbandryProducts(adEnv, source)
elseif source.kind == "storage" then
return getStationProducts(source)
elseif source.kind == "objectStorage" then
return getObjectStorageProducts(source)
end