This commit is contained in:
FullGas1
2025-04-21 02:51:14 +02:00
parent fcef6a66d1
commit d2789f554a

View File

@@ -2046,7 +2046,7 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack'
ctld.logTrace("FG_ ctld.repackVehicle.ctld.repackRequestsStack = %s", ctld.p(ctld.repackRequestsStack)) ctld.logTrace("FG_ ctld.repackVehicle.ctld.repackRequestsStack = %s", ctld.p(ctld.repackRequestsStack))
end end
for ii, v in ipairs(ctld.repackRequestsStack) do for ii, v in ipairs(ctld.repackRequestsStack) do
--ctld.logTrace("FG_ ctld.repackVehicle.v[%s] = %s", ii, ctld.p(v)) ctld.logTrace("FG_ ctld.repackVehicle.v[%s] = %s", ii, ctld.p(v))
local repackableUnitName = v.repackableUnitName local repackableUnitName = v.repackableUnitName
local repackableUnit = Unit.getByName(repackableUnitName) local repackableUnit = Unit.getByName(repackableUnitName)
local crateWeight = v.weight local crateWeight = v.weight
@@ -2065,7 +2065,7 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack'
randomHeading = ctld.RandomReal(playerHeading + math.pi - math.pi/4, playerHeading + math.pi + math.pi/4) randomHeading = ctld.RandomReal(playerHeading + math.pi - math.pi/4, playerHeading + math.pi + math.pi/4)
end end
for i = 1, v.cratesRequired or 1 do for i = 1, v.cratesRequired or 1 do
-- see to spawn the crate at random position heading the transport unnit -- see to spawn the crate at random position heading the transport unit
local _unitId = ctld.getNextUnitId() local _unitId = ctld.getNextUnitId()
local _name = string.format("%s_%i", v.desc, _unitId) local _name = string.format("%s_%i", v.desc, _unitId)
local secureDistance = ctld.getSecureDistanceFromUnit(playerUnitName) or 10 local secureDistance = ctld.getSecureDistanceFromUnit(playerUnitName) or 10
@@ -2077,12 +2077,11 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack'
ctld.spawnCrateStatic(refCountry, _unitId, relativePoint, _name, crateWeight, playerCoa, playerHeading, "dynamic") ctld.spawnCrateStatic(refCountry, _unitId, relativePoint, _name, crateWeight, playerCoa, playerHeading, "dynamic")
end end
end end
repackableUnit:destroy() -- destroy repacked unit repackableUnit:destroy() -- destroy repacked unit
end end
ctld.repackRequestsStack[ii] = nil -- remove the request from the stacking table
end end
--ctld.updateRepackMenu(playerUnitName) -- update the repack menu to process destroyed units --ctld.updateRepackMenu(playerUnitName) -- update the repack menu to process destroyed units
ctld.repackRequestsStack[ii] = nil -- remove the processed request from the stacking table
end end
if ctld.enableRepackingVehicles == true then if ctld.enableRepackingVehicles == true then
return t + 3 -- reschedule the function in 3 seconds return t + 3 -- reschedule the function in 3 seconds