From 6f0ba337c400f1ce1644bad501cb59f401ddee0e Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 21 Dec 2022 12:55:01 +0100 Subject: [PATCH] #SET_SCENERY * Added GetAliveSet() --- Moose Development/Moose/Core/Set.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index cf370d4ce..82a7d65a5 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -6990,7 +6990,29 @@ do -- SET_SCENERY return CountU end + + --- Get a table of alive objects. + -- @param #SET_GROUP self + -- @return #table Table of alive objects + -- @return Core.Set#SET_SCENERY SET of alive objects + function SET_SCENERY:GetAliveSet() + self:F2() + local AliveSet = SET_SCENERY:New() + + -- Clean the Set before returning with only the alive Groups. + for GroupName, GroupObject in pairs( self.Set ) do + local GroupObject = GroupObject -- Wrapper.Group#GROUP + if GroupObject then + if GroupObject:IsAlive() then + AliveSet:Add( GroupName, GroupObject ) + end + end + end + + return AliveSet.Set or {}, AliveSet + end + --- Iterate the SET_SCENERY and call an iterator function for each **alive** SCENERY, providing the SCENERY and optional parameters. -- @param #SET_SCENERY self -- @param #function IteratorFunction The function that will be called when there is an alive SCENERY in the SET_SCENERY. The function needs to accept a SCENERY parameter.