Update OpsGroup.lua

- Storage transport
This commit is contained in:
Frank
2023-08-25 22:15:50 +02:00
parent 7074b70e86
commit 92b0ab3c8d

View File

@@ -9411,7 +9411,19 @@ function OPSGROUP:onafterLoading(From, Event, To)
local function _sort(a, b) local function _sort(a, b)
local cargoA=a --Ops.OpsGroup#OPSGROUP.CargoGroup local cargoA=a --Ops.OpsGroup#OPSGROUP.CargoGroup
local cargoB=b --Ops.OpsGroup#OPSGROUP.CargoGroup local cargoB=b --Ops.OpsGroup#OPSGROUP.CargoGroup
return cargoA.opsgroup:GetWeightTotal()>cargoB.opsgroup:GetWeightTotal() local weightA=0
local weightB=0
if cargoA.opsgroup then
weightA=cargoA.opsgroup:GetWeightTotal()
else
weightA=self:_GetWeightStorage(cargoA.storage)
end
if cargoB.opsgroup then
weightB=cargoB.opsgroup:GetWeightTotal()
else
weightB=self:_GetWeightStorage(cargoB.storage)
end
return weightA>weightB
end end
table.sort(cargos, _sort) table.sort(cargos, _sort)
@@ -9965,6 +9977,9 @@ function OPSGROUP:onafterUnloading(From, Event, To)
-- STORAGE -- STORAGE
--- ---
-- TODO: should proabaly move this check to the top to include OPSGROUPS as well?!
if not cargo.delivered then
for _,_element in pairs(self.elements) do for _,_element in pairs(self.elements) do
local element=_element --#OPSGROUP.Element local element=_element --#OPSGROUP.Element
@@ -10001,7 +10016,7 @@ function OPSGROUP:onafterUnloading(From, Event, To)
local amountTotal=self:_GetWeightStorage(cargo.storage, true, false, true) local amountTotal=self:_GetWeightStorage(cargo.storage, true, false, true)
-- Debug info. -- Debug info.
local text=string.format("FF Amount delivered=%d, total=%d", amountToDeliver, amountTotal) local text=string.format("Amount delivered=%d, total=%d", amountToDeliver, amountTotal)
self:T(self.lid..text) self:T(self.lid..text)
if amountToDeliver<=0 then if amountToDeliver<=0 then
@@ -10012,6 +10027,11 @@ function OPSGROUP:onafterUnloading(From, Event, To)
-- Increase number of delivered cargos. -- Increase number of delivered cargos.
self.cargoTransport.Ndelivered=self.cargoTransport.Ndelivered+1 self.cargoTransport.Ndelivered=self.cargoTransport.Ndelivered+1
-- Debug info.
local text=string.format("Ndelivered=%d delivered=%s", self.cargoTransport.Ndelivered, tostring(cargo.delivered))
self:T(self.lid..text)
end
end end
end end