#Smaller Changes

This commit is contained in:
Applevangelist 2025-04-07 10:40:26 +02:00
parent 6ac452ff15
commit 1856754614
2 changed files with 61 additions and 3 deletions

View File

@ -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.

View File

@ -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