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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user