From 1856754614d9c3d2fc2d7737d4ad020e89b67b0d Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 7 Apr 2025 10:40:26 +0200 Subject: [PATCH] #Smaller Changes --- Moose Development/Moose/Core/Set.lua | 58 ++++++++++++++++++++++++++++ Moose Development/Moose/Ops/CTLD.lua | 6 +-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 0b54f06d0..c66b3cf57 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -2519,6 +2519,35 @@ do -- SET_UNIT ) return self end + + --- Builds a set of units which belong to groups with certain **group names**. + -- @param #SET_UNIT self + -- @param #string Prefixes The (partial) group names to look for. Can be a single string or a table of strings. + -- @return #SET_UNIT self + function SET_UNIT:FilterGroupPrefixes(Prefixes) + if type(Prefixes) == "string" then + Prefixes = {Prefixes} + end + self:FilterFunction( + function(unit,prefixes) + local outcome = false + if unit then + local grp = unit:GetGroup() + local gname = grp ~= nil and grp:GetName() or "none" + for _,_fix in pairs(prefixes or {}) do + if string.find(gname,_fix) then + outcome = true + break + end + end + else + return false + end + return outcome + end, Prefixes + ) + return self + end --- Builds a set of units having a radar of give types. -- All the units having a radar of a given type will be included within the set. @@ -4434,6 +4463,35 @@ do -- SET_CLIENT end return self end + + --- Builds a set of clients which belong to groups with certain **group names**. + -- @param #SET_CLIENT self + -- @param #string Prefixes The (partial) group names to look for. Can be anywhere in the group name. Can be a single string or a table of strings. + -- @return #SET_CLIENT self + function SET_CLIENT:FilterGroupPrefixes(Prefixes) + if type(Prefixes) == "string" then + Prefixes = {Prefixes} + end + self:FilterFunction( + function(unit,prefixes) + local outcome = false + if unit then + local grp = unit:GetGroup() + local gname = grp ~= nil and grp:GetName() or "none" + for _,_fix in pairs(prefixes or {}) do + if string.find(gname,_fix) then + outcome = true + break + end + end + else + return false + end + return outcome + end, Prefixes + ) + return self + end --- Builds a set of clients that are only active. -- Only the clients that are active will be included within the set. diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 2510aa35e..565c9bf1a 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -4222,7 +4222,7 @@ function CTLD:_RefreshF10Menus() local client = _clientobj -- Wrapper.Client#CLIENT if client:IsGround() then local cname = client:GetName() - --self:I(self.lid.."Adding: "..cname) + self:T(self.lid.."Adding: "..cname) _UnitList[cname] = cname end end @@ -4256,7 +4256,7 @@ function CTLD:_RefreshF10Menus() local menus = {} for _, _unitName in pairs(self.CtldUnits) do if (not self.MenusDone[_unitName]) or (self.showstockinmenuitems == true) then - --self:I(self.lid.."Menu not done yet") + self:T(self.lid.."Menu not done yet for ".._unitName) local _unit = UNIT:FindByName(_unitName) if not _unit and self.allowCATransport then _unit = CLIENT:FindByName(_unitName) @@ -4264,7 +4264,7 @@ function CTLD:_RefreshF10Menus() if _unit and _unit:IsAlive() then local _group = _unit:GetGroup() if _group then - --self:I(self.lid.."Unit and Group exist") + self:T(self.lid.."Unit and Group exist") local capabilities = self:_GetUnitCapabilities(_unit) local cantroops = capabilities.troops local cancrates = capabilities.crates