fix: pallevarer accepteres via supportedFillTypes (palletrigger); log med fundne salgsmarkører når ingen tager varen (v1.12.16.0)
This commit is contained in:
@@ -232,6 +232,21 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
|
||||
local homeId = product.sources[1] ~= nil and product.sources[1].wayPointId or nil
|
||||
local quote, unreachableName = findSellQuote(adEnv, vehicle, product, sellMarkers, run.sellAtPercent, homeId)
|
||||
product.quote = quote
|
||||
if quote == nil and unreachableName == nil then
|
||||
-- intet salgssted tager varen: sig hvilke salgsmarkører der findes, og hvad de tager
|
||||
local found = {}
|
||||
for _, entry in ipairs(sellMarkers) do
|
||||
local accepted = ADSources.describeAccepted ~= nil and ADSources.describeAccepted(entry.station) or "?"
|
||||
table.insert(found, string.format("%s (%s)", tostring(entry.marker.name), accepted))
|
||||
end
|
||||
local key = "nosell:" .. product.name
|
||||
local text = string.format("intet salgssted tager %s — salgsmarkører: %s", product.name, #found > 0 and table.concat(found, "; ") or "ingen (sæt en markør ved et salgssted)")
|
||||
if warned[vehicle] == nil or warned[vehicle][key] ~= text then
|
||||
warned[vehicle] = warned[vehicle] or {}
|
||||
warned[vehicle][key] = text
|
||||
Logging.info(ADOutbound.LOG_PREFIX .. "'%s': %s", tostring(vehicle:getName()), text)
|
||||
end
|
||||
end
|
||||
-- gårdens eget behov (fabrikker/stalde) sælges ikke; kilderne selv tæller ikke som forbrugere
|
||||
if ADSources.getFarmDemand ~= nil then
|
||||
local demand = ADSources.getFarmDemand(adEnv, product.fillType, farmId, ADSources.getSourcePlaceables(sources))
|
||||
|
||||
@@ -314,14 +314,39 @@ function ADSources.spawnOne(source, objectInfoIndex)
|
||||
return ok == true
|
||||
end
|
||||
|
||||
-- acceptedFillTypes rummer kun bulk-triggerens varer; palletriggerens varer ligger i
|
||||
-- supportedFillTypes (det AutoDrive selv slår op i). Begge tæller.
|
||||
function ADSources.stationAccepts(station, fillType)
|
||||
if station.acceptedFillTypes ~= nil then
|
||||
return station.acceptedFillTypes[fillType] == true
|
||||
if station.acceptedFillTypes ~= nil and station.acceptedFillTypes[fillType] == true then
|
||||
return true
|
||||
end
|
||||
if station.supportedFillTypes ~= nil and station.supportedFillTypes[fillType] == true then
|
||||
return true
|
||||
end
|
||||
if station.getIsFillTypeSupported ~= nil then
|
||||
return station:getIsFillTypeSupported(fillType) == true
|
||||
local ok, value = pcall(station.getIsFillTypeSupported, station, fillType)
|
||||
return ok and value == true
|
||||
end
|
||||
return station.supportedFillTypes ~= nil and station.supportedFillTypes[fillType] == true
|
||||
return false
|
||||
end
|
||||
|
||||
-- Til loggen: navnene på de varer stationen tager (sorteret), fx "SUGAR, STRAW_BASKET".
|
||||
function ADSources.describeAccepted(station)
|
||||
local set = {}
|
||||
for _, field in ipairs({"acceptedFillTypes", "supportedFillTypes"}) do
|
||||
for fillType, accepted in pairs(station[field] or {}) do
|
||||
if accepted == true then set[fillType] = true end
|
||||
end
|
||||
end
|
||||
local names = {}
|
||||
for fillType in pairs(set) do
|
||||
table.insert(names, g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(fillType) or tostring(fillType))
|
||||
end
|
||||
table.sort(names, function(a, b)
|
||||
-- stabil rækkefølge efter indeks hvor det kendes, ellers navn
|
||||
return tostring(a) < tostring(b)
|
||||
end)
|
||||
return table.concat(names, ", ")
|
||||
end
|
||||
|
||||
-- Markører hvis aflæsningsstation er et rigtigt salgssted: { {marker, station} }.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.12.15.0</version>
|
||||
<version>1.12.16.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user