fix: stald-markør giver kun varerne fra sit eget læssepunkt (mælk vs. gylle i hver sin ende) (v1.13.4.0)

This commit is contained in:
2026-09-24 00:39:33 +02:00
parent 86b76f4ee1
commit 25332184a8
3 changed files with 59 additions and 6 deletions
+34 -5
View File
@@ -323,11 +323,40 @@ local function getObjectStorageProducts(source)
end
-- Stald: det læssestationen udleverer (mælk, gylle ...) med staldens eget niveau/kapacitet.
local function getHusbandryProducts(source)
-- Varerne det læssepunkt udleverer som står nærmest markøren (en stald kan have mælk i den ene ende
-- og gylle i den anden på samme station). nil når punktet ikke opgiver sine varer.
local function getNearestTriggerFillTypes(adEnv, source)
local station = source.station
local wayPoint = adEnv.ADGraphManager:getWayPointById(source.wayPointId)
if station == nil or wayPoint == nil or station.loadTriggers == nil then
return nil
end
local best, bestDistance = nil, math.huge
for _, trigger in pairs(station.loadTriggers) do
local x, z = getNodePosition(trigger.triggerNode)
if x ~= nil then
local d = distance2(wayPoint.x, wayPoint.z, x, z)
if d < bestDistance then best, bestDistance = trigger, d end
end
end
if best == nil or type(best.fillTypes) ~= "table" or next(best.fillTypes) == nil then
return nil
end
local list = {}
for key, value in pairs(best.fillTypes) do
-- FS25 gemmer som sæt {[ft] = true}; nogle mods som liste {ft, ...}
if value == true then table.insert(list, key) elseif type(value) == "number" then table.insert(list, value) end
end
return #list > 0 and list or nil
end
local function getHusbandryProducts(adEnv, source)
local placeable, station = source.placeable, source.station
local fillTypes = {}
for fillType, supported in pairs(station ~= nil and station.supportedFillTypes or {}) do
if supported == true then table.insert(fillTypes, fillType) end
local fillTypes = getNearestTriggerFillTypes(adEnv, source) or {}
if #fillTypes == 0 then
for fillType, supported in pairs(station ~= nil and station.supportedFillTypes or {}) do
if supported == true then table.insert(fillTypes, fillType) end
end
end
if #fillTypes == 0 and station ~= nil and station.getIsFillTypeSupported ~= nil and g_fillTypeManager ~= nil then
for _, name in ipairs({"MILK", "GOATMILK", "BUFFALOMILK", "SHEEPMILK", "LIQUIDMANURE", "MANURE", "DIGESTATE"}) do
@@ -358,7 +387,7 @@ function ADSources.getProducts(adEnv, source, farmId)
elseif source.kind == "silo" then
return getSiloProducts(source)
elseif source.kind == "husbandry" then
return getHusbandryProducts(source)
return getHusbandryProducts(adEnv, source)
elseif source.kind == "objectStorage" then
return getObjectStorageProducts(source)
end
+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.13.3.0</version>
<version>1.13.4.0</version>
<title>
<en>AD Smart Pickup</en>
</title>