fix(silo): varer = læssestationens pulje (tom mælketank med fuld pulje viste ingen mælk -> noProducts); sammenlægning af kilder kun for siloer, ikke staldes mælke/gyllepunkter (v1.17.4.0)

This commit is contained in:
2026-09-24 04:01:26 +02:00
parent edf6805cac
commit c0f523700e
7 changed files with 51 additions and 4 deletions
+5 -1
View File
@@ -64,7 +64,11 @@ end
-- Lagrene en kildes læssestation trækker fra (FS25: sourceStorages = {[storage] = storage}); nil = ukendt. -- Lagrene en kildes læssestation trækker fra (FS25: sourceStorages = {[storage] = storage}); nil = ukendt.
local function sourceStorages(source) local function sourceStorages(source)
local station = source ~= nil and source.station or nil -- kun siloer: en stalds mælke- og gyllepunkt deler også lager, men er forskellige læssepunkter
if source == nil or source.kind ~= "silo" then
return nil
end
local station = source.station
if station == nil or type(station.sourceStorages) ~= "table" then if station == nil or type(station.sourceStorages) ~= "table" then
return nil return nil
end end
+15
View File
@@ -286,6 +286,21 @@ local function getSiloProducts(source)
end end
end end
end end
-- Udvidelses-lagre (fx mælketanke med isExtension) deles af alle læssestationer inden for
-- storageRadius: tanken selv kan være tom mens puljen er fuld. Læssestationens tal er det man kan hente.
local station = source.station
if station ~= nil and station.getAllFillLevels ~= nil then
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or 1
local ok, pooled, pooledCapacity = pcall(station.getAllFillLevels, station, farmId)
if ok and type(pooled) == "table" then
for fillType, level in pairs(pooled) do
if (level or 0) > (levels[fillType] or 0) then
levels[fillType] = level
capacities[fillType] = math.max(capacities[fillType] or 0, tonumber(pooledCapacity) or 0, level)
end
end
end
end
local products = {} local products = {}
for fillType, level in pairs(levels) do for fillType, level in pairs(levels) do
table.insert(products, newProduct(fillType, level, level, capacities[fillType] or 0, false)) table.insert(products, newProduct(fillType, level, level, capacities[fillType] or 0, false))
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107"> <modDesc descVersion="107">
<author>masterdraco</author> <author>masterdraco</author>
<version>1.17.3.0</version> <version>1.17.4.0</version>
<title> <title>
<en>AD Smart Pickup</en> <en>AD Smart Pickup</en>
</title> </title>
+1 -1
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — brugermanual # AD Smart Pickup — brugermanual
Version 1.17.3 · Farming Simulator 25 · tillæg til AutoDrive Version 1.17.4 · Farming Simulator 25 · tillæg til AutoDrive
*English version: [USER_MANUAL.md](USER_MANUAL.md)* *English version: [USER_MANUAL.md](USER_MANUAL.md)*
+1 -1
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — user manual # AD Smart Pickup — user manual
Version 1.17.3 · Farming Simulator 25 · add-on for AutoDrive Version 1.17.4 · Farming Simulator 25 · add-on for AutoDrive
*Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)* *Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)*
+21
View File
@@ -549,6 +549,8 @@ do
local st1, st2 = sources[1].station, sources[2].station local st1, st2 = sources[1].station, sources[2].station
sources[1].station = {name = "tankA", sourceStorages = {[pool] = pool}} sources[1].station = {name = "tankA", sourceStorages = {[pool] = pool}}
sources[2].station = {name = "tankB", sourceStorages = {[pool] = pool}} sources[2].station = {name = "tankB", sourceStorages = {[pool] = pool}}
local k1, k2 = sources[1].kind, sources[2].kind
sources[1].kind, sources[2].kind = "silo", "silo"
local vPool = newVehicle("Tank", 0, 0, 10000) local vPool = newVehicle("Tank", 0, 0, 10000)
runs[vPool] = outboundRun(77, {1, 2}, {{fillType = "SUGAR", policy = "sell"}}, {collectRound = true}) runs[vPool] = outboundRun(77, {1, 2}, {{fillType = "SUGAR", policy = "sell"}}, {collectRound = true})
local inputPool = ADOutbound.buildPlanInput(adEnv, runs[vPool], vPool) local inputPool = ADOutbound.buildPlanInput(adEnv, runs[vPool], vPool)
@@ -559,6 +561,25 @@ do
check("O-pool kun første kilde", table.concat(ids, ","), "1") check("O-pool kun første kilde", table.concat(ids, ","), "1")
check("O-pool logget", lastLog("deler lager") ~= nil, true) check("O-pool logget", lastLog("deler lager") ~= nil, true)
sources[1].station, sources[2].station = st1, st2 sources[1].station, sources[2].station = st1, st2
sources[1].kind, sources[2].kind = k1, k2
end
-- O-pool-stald: mælke- og gyllemarkør ved samme stald deler lager, men er forskellige læssepunkter
do
local pool = {}
sources[31] = {kind = "husbandry", wayPointId = 31, station = {name = "barnSlurry", sourceStorages = {[pool] = pool}}, name = "Stald"}
sources[32] = {kind = "husbandry", wayPointId = 32, station = {name = "barnMilk", sourceStorages = {[pool] = pool}}, name = "Stald"}
products[31] = {{fillType = SUGAR_FT or 5, name = "SUGAR", title = "Sukker", available = 20000, level = 20000, capacity = 50000, isPallet = false}}
products[32] = {{fillType = SUGAR_FT or 5, name = "SUGAR", title = "Sukker", available = 20000, level = 20000, capacity = 50000, isPallet = false}}
local vBarn = newVehicle("Tank2", 0, 0, 10000)
runs[vBarn] = outboundRun(78, {31, 32}, {{fillType = "SUGAR", policy = "sell"}}, {collectRound = true})
local inputBarn = ADOutbound.buildPlanInput(adEnv, runs[vBarn], vBarn)
local ids = {}
for _, product in ipairs(inputBarn.products) do
for _, source in ipairs(product.sources) do table.insert(ids, tostring(source.wayPointId)) end
end
check("O-pool-stald: stalde lægges ikke sammen", table.concat(ids, ","), "31,32")
sources[31], sources[32], products[31], products[32] = nil, nil, nil, nil
end end
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
+7
View File
@@ -370,6 +370,13 @@ check("S14b stald + udvidelsestank", products14b[1].level, 138187)
check("S14b tilgængeligt = samlet", products14b[1].available, 138187) check("S14b tilgængeligt = samlet", products14b[1].available, 138187)
milkStation.getAllFillLevels = nil milkStation.getAllFillLevels = nil
-- S14c: mælketank (silo med udvidelses-lager) — tanken selv er tom, puljen via læssestationen har mælken
local tank = {spec_silo = {storages = {{fillLevels = {}, getCapacity = function() return 10000000 end}}}}
local tankSource = {kind = "silo", placeable = tank, wayPointId = 999, station = {getAllFillLevels = function() return {[MILK] = 500000}, 70000000 end}}
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)
-- S15: forklaring af en markør til advarslen (hvad opslaget ser) -- 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 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") check("S15 forklaring ingen station", ADSources.explainMarker(adEnv, 4, 1), "ingen læssestation ved markøren, og ingen fabrik/objektlager inden for 40 m")