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
+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