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
+10
View File
@@ -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
+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
+1
View File
@@ -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 —"/>
+1
View File
@@ -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 -1
View File
@@ -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>
+2 -1
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — brugermanual
Version 1.18.3 · Farming Simulator 25 · tillæg til AutoDrive
Version 1.18.4 · Farming Simulator 25 · tillæg til AutoDrive
*English version: [USER_MANUAL.md](USER_MANUAL.md)*
@@ -275,6 +275,7 @@ Under **Fra** kan du vælge:
| **Silo** | Siloens indhold |
| **Stald** | Mælk, gylle og gødning fra staldens læssepunkter, inklusive tilknyttede udvidelsestanke som Milk Tank Extension |
| **Objektlager** | Paller og baller. De tages ud én ad gangen |
| **Lager** | Andre bygninger med en læssestation, fx Pumps & Hoses' separatorhal med digestat. Varerne læses fra læssestationen |
**Kilder med fælles lager:** nogle lagre er udvidelser, der deler beholdning med alle inden for en
vis afstand, fx mælketanke i en række. Læsser man ved én, tømmes de alle. Moden opdager det selv og
+2 -1
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — user manual
Version 1.18.3 · Farming Simulator 25 · add-on for AutoDrive
Version 1.18.4 · Farming Simulator 25 · add-on for AutoDrive
*Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)*
@@ -278,6 +278,7 @@ Under **From** you can pick:
| **Silo** | The silo's contents |
| **Barn** | Milk, slurry and manure from the barn's loading points, including attached extension tanks such as Milk Tank Extension |
| **Object storage** | Pallets and bales. They are taken out one at a time |
| **Storage** | Other buildings with a loading station, such as the Pumps & Hoses separator hall with digestate. The goods are read from the loading station |
**Sources with shared storage:** some storages are extensions that share their stock with everything
within a set distance, such as a row of milk tanks. Loading at one empties them all. The mod detects
+13
View File
@@ -149,5 +149,18 @@ do
check("B-DOB almindelig silo stadig ikke mål", byIdDob.silo1.canBeTarget, false)
end
-- B-SEP: bygning med læssestation men uden silo/fabrik/stald-spec (Pumps&Hoses separatorhal: digestat-udlevering)
do
local sep = placeable("sep1", "Separator Hall", 7000, 0, {spec_manureSeparator = {}})
table.insert(loadStations, {owningPlaceable = sep, loadTriggers = {{triggerNode = {x = 7000, z = 5}}}})
addMarker(41, "Digestate pickup", "Biogas", 7000, 10)
ADBuildings.invalidate()
local bySep = {}
for _, b in ipairs(ADBuildings.list(adEnv, 1)) do bySep[b.id] = b end
check("B-SEP findes som lager", bySep.sep1 and bySep.sep1.kind, "storage")
check("B-SEP kan være kilde", bySep.sep1 and bySep.sep1.canBeSource, true)
check("B-SEP læssemarkør", bySep.sep1 and bySep.sep1.loadMarker and bySep.sep1.loadMarker.id, 41)
end
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1)
+12
View File
@@ -377,6 +377,18 @@ local tankProducts = ADSources.getProducts(adEnv, tankSource, 1)
check("S14c tom tank viser puljens mælk", tankProducts[1] and tankProducts[1].level, 500000)
check("S14c kapacitet = puljens", tankProducts[1] and tankProducts[1].capacity, 70000000)
-- S14d: generelt lager (separatorhal): kilde via læssestationen, varer = stationens niveauer
local DIGESTATE = 30
DESC[DIGESTATE] = {index = DIGESTATE, name = "DIGESTATE", title = "Digestat"}
local separator = {rootNode = {x = 7000, z = 0}, ownerFarmId = 1, getOwnerFarmId = function() return 1 end, getName = function() return "Separator Hall" end, spec_manureSeparator = {}}
local sepStation = {owningPlaceable = separator, supportedFillTypes = {[DIGESTATE] = true}, getAllFillLevels = function() return {[DIGESTATE] = 42000}, 200000 end}
addMarker(77, "Digestate pickup", 7000, 10); loadAt[77] = sepStation
local sepSource = ADSources.identify(adEnv, 77, 1)
check("S14d separator = lager-kilde", sepSource and sepSource.kind, "storage")
local sepProducts = sepSource and ADSources.getProducts(adEnv, sepSource, 1) or {}
check("S14d digestat fra stationen", sepProducts[1] and sepProducts[1].fillType, DIGESTATE)
check("S14d mængde", sepProducts[1] and sepProducts[1].level, 42000)
-- S15: forklaring af en markør til advarslen (hvad opslaget ser)
check("S15 forklaring stald", ADSources.explainMarker(adEnv, 10, 1), "læssestation ved markøren hører til 'Kostald' (stald)")
check("S15 forklaring ingen station", ADSources.explainMarker(adEnv, 4, 1), "ingen læssestation ved markøren, og ingen fabrik/objektlager inden for 40 m")