From 763bfb4bb1992033b5e2d3a79cf2ba8a15bfc58a Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:41:30 +0100 Subject: [PATCH] Update DynamicCargo.lua Added Destroy-Functionality --- .../Moose/Wrapper/DynamicCargo.lua | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/DynamicCargo.lua b/Moose Development/Moose/Wrapper/DynamicCargo.lua index 8c4987f72..76a874198 100644 --- a/Moose Development/Moose/Wrapper/DynamicCargo.lua +++ b/Moose Development/Moose/Wrapper/DynamicCargo.lua @@ -534,7 +534,10 @@ function DYNAMICCARGO:_UpdatePosition() --------------- -- REMOVED Cargo --------------- - if self.timer and self.timer:IsRunning() then self.timer:Stop() end + if self.timer and self.timer:IsRunning() then + self.timer:Stop() + self.timer=nil + end self:T(self.lid.." dead! " ..self.CargoState.."-> REMOVED") self.CargoState = DYNAMICCARGO.State.REMOVED _DATABASE:CreateEventDynamicCargoRemoved(self) @@ -542,6 +545,24 @@ function DYNAMICCARGO:_UpdatePosition() return self end +--- [USER] Destroy a DYNAMICCARGO object. +-- @param #DYNAMICCARGO self +-- @param #boolean GenerateEvent Set to false to remove an item silently. Defaults to true. +-- @return #boolean Return Returns nil if the object could not be found, else returns true. +function DYNAMICCARGO:Destroy(GenerateEvent) + local DCSObject = self:GetDCSObject() + if DCSObject then + local GenerateEvent = (GenerateEvent ~= nil and GenerateEvent == false) and false or true + if GenerateEvent and GenerateEvent == true then + self:CreateEventDead( timer.getTime(), DCSObject ) + end + DCSObject:destroy() + self:_UpdatePosition() + return true + end + return nil +end + --- [Internal] Track helos for loaded/unloaded decision making. -- @param Wrapper.Client#CLIENT client -- @return #boolean IsIn