feat: paller — 'fuldt læs' for autoload-bil = mindst 4 paller klar (ved spawner eller i objektlager) (v1.12.14.0)

This commit is contained in:
2026-09-23 15:30:51 +02:00
parent 2714d11ab8
commit b6c729ac59
7 changed files with 46 additions and 13 deletions
+1 -1
View File
@@ -220,7 +220,7 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
byName[item.name] = product
table.insert(products, product)
end
table.insert(product.sources, {wayPointId = source.wayPointId, available = available, level = item.level, capacity = item.capacity})
table.insert(product.sources, {wayPointId = source.wayPointId, available = available, level = item.level, capacity = item.capacity, palletCount = usePallets and (item.palletCount or 0) or 0})
end
end
end
+14 -4
View File
@@ -20,6 +20,8 @@ ADOutboundPlanner = {}
ADOutboundPlanner.MIN_AVAILABLE_LITERS = 1
-- Opsamlingsrunde (bulk): næste kilde besøges kun hvis mindst så stor en andel af vognen er fri.
ADOutboundPlanner.ROUND_MIN_FREE_FRACTION = 0.1
-- Paller: en autoload-bil opgiver ingen liter-kapacitet, så "fuldt læs" = mindst så mange paller klar.
ADOutboundPlanner.PALLET_FULL_LOAD_COUNT = 4
local function wantsSell(policy)
return policy == "sell" or policy == "sellElseStore"
@@ -31,25 +33,33 @@ end
-- Samlet tilgængeligt over kilderne og den højeste fyldningsgrad (%) blandt dem.
local function sumSources(product)
local total, percent = 0, 0
local total, percent, pallets = 0, 0, 0
for _, source in ipairs(product.sources or {}) do
total = total + (source.available or 0)
pallets = pallets + (source.palletCount or 0)
if source.capacity ~= nil and source.capacity > 0 then
percent = math.max(percent, 100 * (source.level or 0) / source.capacity)
end
end
return total, percent
return total, percent, pallets
end
function ADOutboundPlanner.evaluate(product, input)
local available, storagePercent = sumSources(product)
local available, storagePercent, palletCount = sumSources(product)
local percent = product.quote ~= nil and product.quote.percent or nil
local reserve = math.max(0, product.reserve or 0)
local fullLoad
if input.capacity ~= nil and input.capacity > 0 then
fullLoad = available >= input.capacity
else
fullLoad = product.isPallet == true and palletCount >= ADOutboundPlanner.PALLET_FULL_LOAD_COUNT
end
return {
available = available,
reserve = reserve,
sellable = math.max(0, available - reserve),
fullLoad = input.capacity ~= nil and input.capacity > 0 and available >= input.capacity,
palletCount = palletCount,
fullLoad = fullLoad,
storagePercent = storagePercent,
storageHigh = storagePercent >= (input.storeAbovePercent or 80),
percent = percent,
+12 -6
View File
@@ -174,7 +174,7 @@ local function getPalletsNearSpawner(placeable, fillType, farmId)
return 0
end
local vehicles = g_currentMission ~= nil and g_currentMission.vehicleSystem ~= nil and g_currentMission.vehicleSystem.vehicles or {}
local total = 0
local total, count = 0, 0
local radius2 = ADSources.PALLET_RADIUS * ADSources.PALLET_RADIUS
for _, vehicle in pairs(vehicles) do
if isPalletVehicle(vehicle) and (vehicle.getOwnerFarmId == nil or vehicle:getOwnerFarmId() == farmId) then
@@ -182,10 +182,11 @@ local function getPalletsNearSpawner(placeable, fillType, farmId)
local x, z = getNodePosition(vehicle.rootNode)
if palletFillType == fillType and x ~= nil and distance2(sx, sz, x, z) <= radius2 then
total = total + level
count = count + 1
end
end
end
return total
return total, count
end
-- canPallet: varen er en palletype (kan stå på paller); palletLiters: liter på paller ved
@@ -193,7 +194,7 @@ end
local function newProduct(fillType, available, level, capacity, isPallet)
local name = g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(fillType) or tostring(fillType)
local title = g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeTitleByIndex ~= nil and g_fillTypeManager:getFillTypeTitleByIndex(fillType) or nil
return {fillType = fillType, name = name, title = title or name, available = available, level = level, capacity = capacity, isPallet = isPallet, canPallet = isPallet or ADSources.isPalletFillType(fillType), palletLiters = 0}
return {fillType = fillType, name = name, title = title or name, available = available, level = level, capacity = capacity, isPallet = isPallet, canPallet = isPallet or ADSources.isPalletFillType(fillType), palletLiters = 0, palletCount = 0}
end
local function getFactoryProducts(source, farmId)
@@ -208,10 +209,13 @@ local function getFactoryProducts(source, farmId)
local level = storage ~= nil and storage.getFillLevel ~= nil and (storage:getFillLevel(fillType) or 0) or 0
local capacity = storage ~= nil and storage.getCapacity ~= nil and (storage:getCapacity(fillType) or 0) or 0
local isPallet = ADSources.isPalletAt(source, fillType)
local palletLiters = ADSources.isPalletFillType(fillType) and getPalletsNearSpawner(source.placeable, fillType, farmId) or 0
local palletLiters, palletCount = 0, 0
if ADSources.isPalletFillType(fillType) then
palletLiters, palletCount = getPalletsNearSpawner(source.placeable, fillType, farmId)
end
local available = level + (isPallet and palletLiters or 0)
local product = newProduct(fillType, available, level, capacity, isPallet)
product.palletLiters = palletLiters
product.palletLiters, product.palletCount = palletLiters, palletCount
table.insert(products, product)
end
end
@@ -258,7 +262,9 @@ local function getObjectStorageProducts(source)
local fillType, perObject = getObjectInfoContent(objectInfo)
local count = objectInfo.numObjects or 0
if fillType ~= nil and count > 0 then
table.insert(products, newProduct(fillType, count * perObject, spec.numStoredObjects or count, spec.capacity or 0, true))
local product = newProduct(fillType, count * perObject, spec.numStoredObjects or count, spec.capacity or 0, true)
product.palletCount = count
table.insert(products, product)
end
end
return products
+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.12.13.0</version>
<version>1.12.14.0</version>
<title>
<en>AD Smart Pickup</en>
</title>