fix: påfyldningsniveau via getFillUnitFillType; tom-meldinger viser vognens indhold (v1.62.121)
This commit is contained in:
@@ -326,13 +326,34 @@ function ADCpBridge.getRefillFillType(vehicle, role)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Hvad sættet faktisk har på (til "er tom"-loggen): "K105: FERTILIZER 10000 l" ...
|
||||
function ADCpBridge.describeFill(vehicle)
|
||||
local parts = {}
|
||||
for _, object in ipairs(collect(vehicle)) do
|
||||
pcall(function()
|
||||
for index in ipairs(object.spec_fillUnit ~= nil and object.spec_fillUnit.fillUnits or {}) do
|
||||
local level = object:getFillUnitFillLevel(index) or 0
|
||||
if level > 0 then
|
||||
local ft = object.getFillUnitFillType ~= nil and object:getFillUnitFillType(index) or nil
|
||||
local name = ft ~= nil and g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeNameByIndex(ft) or tostring(ft)
|
||||
table.insert(parts, string.format("%s: %s %.0f l", tostring(object.getName ~= nil and object:getName() or "?"), tostring(name), level))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
return #parts > 0 and table.concat(parts, ", ") or "intet"
|
||||
end
|
||||
|
||||
-- Hvor meget af påfyldningsvaren sættet har tilbage (liter, alle fyldenheder med varen).
|
||||
function ADCpBridge.getRefillLevel(vehicle, fillType)
|
||||
local total = 0
|
||||
for _, object in ipairs(collect(vehicle)) do
|
||||
pcall(function()
|
||||
for index, unit in ipairs(object.spec_fillUnit ~= nil and object.spec_fillUnit.fillUnits or {}) do
|
||||
if unit.fillType == fillType then total = total + (object:getFillUnitFillLevel(index) or 0) end
|
||||
-- spillets egen funktion: feltet unit.fillType er ikke altid opdateret (in-game 9/10: K105 Unrealistic
|
||||
-- med 10 t gødning blev meldt "tom", sendt på læs-tur og kørte fuld direkte til marken)
|
||||
local current = object.getFillUnitFillType ~= nil and object:getFillUnitFillType(index) or unit.fillType
|
||||
if current == fillType then total = total + (object:getFillUnitFillLevel(index) or 0) end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user