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:
@@ -203,6 +203,13 @@ local function isSellPlaceable(placeable, unloadStations)
|
||||
return false
|
||||
end
|
||||
|
||||
local function hasOwnLoadingStation(placeable, loadStations)
|
||||
for _, station in pairs(loadStations) do
|
||||
if station.owningPlaceable == placeable then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function build(adEnv, farmId)
|
||||
local placeables = g_currentMission ~= nil and g_currentMission.placeableSystem ~= nil and g_currentMission.placeableSystem.placeables or {}
|
||||
local storage = g_currentMission ~= nil and g_currentMission.storageSystem or nil
|
||||
@@ -213,6 +220,9 @@ local function build(adEnv, farmId)
|
||||
local kind = getKind(placeable)
|
||||
local isSell = kind == nil and isSellPlaceable(placeable, unloadStations)
|
||||
if isSell then kind = "sell" end
|
||||
-- generelt lager: gårdens bygning med egen læssestation uden silo/fabrik/stald-spec
|
||||
-- (fx Pumps&Hoses' separatorhal der udleverer digestat)
|
||||
if kind == nil and hasOwnLoadingStation(placeable, loadStations) then kind = "storage" end
|
||||
if kind ~= nil and (kind == "sell" or isOwnedBy(placeable, farmId)) then
|
||||
local id = ADBuildings.getId(placeable)
|
||||
if id ~= nil then
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
<text name="spu_source_kind_factory" text="fabrik"/>
|
||||
<text name="spu_source_kind_silo" text="silo"/>
|
||||
<text name="spu_source_kind_objectStorage" text="objektlager"/>
|
||||
<text name="spu_source_kind_storage" text="lager"/>
|
||||
<text name="spu_tab_flows" text="Flows"/>
|
||||
<text name="spu_section_flows" text="— Flows (Vare · Fra → Til · Regel · Traktorer · Status) —"/>
|
||||
<text name="spu_section_flow" text="— Ret flow: %s —"/>
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
<text name="spu_source_kind_factory" text="factory"/>
|
||||
<text name="spu_source_kind_silo" text="silo"/>
|
||||
<text name="spu_source_kind_objectStorage" text="object storage"/>
|
||||
<text name="spu_source_kind_storage" text="storage"/>
|
||||
<text name="spu_tab_flows" text="Flows"/>
|
||||
<text name="spu_section_flows" text="— Flows (Goods · From → To · Rule · Tractors · Status) —"/>
|
||||
<text name="spu_section_flow" text="— Edit flow: %s —"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.18.3.0</version>
|
||||
<version>1.18.4.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user