Merge remote-tracking branch 'origin/master' into develop

# Conflicts:
#	Moose Development/Moose/Wrapper/Group.lua
This commit is contained in:
Applevangelist 2023-11-08 17:54:58 +01:00
commit 9cb4f166f2
3 changed files with 56 additions and 5 deletions

View File

@ -11,7 +11,7 @@ on:
branches: ["master"] branches: ["master"]
paths: paths:
- 'docs/**' - 'docs/**'
- '.github/workflows/pages.yml' - '.github/workflows/gh-pages.yml'
# Allows you to run this workflow manually from the Actions tab # Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:
@ -75,4 +75,4 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
- run: npm install linkinator - run: npm install linkinator
- run: npx linkinator https://flightcontrol-master.github.io/MOOSE/ --verbosity error --timeout 5000 --recurse - run: npx linkinator https://flightcontrol-master.github.io/MOOSE/ --verbosity error --timeout 5000 --recurse --skip "(java.com)"

View File

@ -52,8 +52,8 @@
-- --
-- * @{#GROUP.Find}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Group object. -- * @{#GROUP.Find}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Group object.
-- * @{#GROUP.FindByName}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Group name. -- * @{#GROUP.FindByName}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Group name.
-- * @{#GROUP:FindByMatching}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using pattern matching. -- * @{#GROUP.FindByMatching}(): Find a GROUP instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using pattern matching.
-- * @{#GROUP:FindByAllMatching}(): Find all GROUP instances from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using pattern matching. -- * @{#GROUP.FindAllByMatching}(): Find all GROUP instances from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using pattern matching.
-- --
-- ## Tasking of groups -- ## Tasking of groups
-- --

View File

@ -13,7 +13,7 @@
-- --
-- ### Author: **FlightControl** -- ### Author: **FlightControl**
-- --
-- ### Contributions: **funkyfranky** -- ### Contributions: **funkyfranky**, **Applevangelist**
-- --
-- === -- ===
-- --
@ -42,6 +42,8 @@
-- --
-- * @{#UNIT.Find}(): Find a UNIT instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Unit object. -- * @{#UNIT.Find}(): Find a UNIT instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Unit object.
-- * @{#UNIT.FindByName}(): Find a UNIT instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Unit name. -- * @{#UNIT.FindByName}(): Find a UNIT instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a DCS Unit name.
-- * @{#UNIT.FindByMatching}(): Find a UNIT instance from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a pattern.
-- * @{#UNIT.FindAllByMatching}(): Find all UNIT instances from the global _DATABASE object (an instance of @{Core.Database#DATABASE}) using a pattern.
-- --
-- IMPORTANT: ONE SHOULD NEVER SANITIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil). -- IMPORTANT: ONE SHOULD NEVER SANITIZE these UNIT OBJECT REFERENCES! (make the UNIT object references nil).
-- --
@ -160,6 +162,55 @@ function UNIT:FindByName( UnitName )
return UnitFound return UnitFound
end end
--- Find the first(!) UNIT matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
-- @param #UNIT self
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
-- @return #UNIT The UNIT.
-- @usage
-- -- Find a group with a partial group name
-- local unit = UNIT:FindByMatching( "Apple" )
-- -- will return e.g. a group named "Apple-1-1"
--
-- -- using a pattern
-- local unit = UNIT:FindByMatching( ".%d.%d$" )
-- -- will return the first group found ending in "-1-1" to "-9-9", but not e.g. "-10-1"
function UNIT:FindByMatching( Pattern )
local GroupFound = nil
for name,group in pairs(_DATABASE.UNITS) do
if string.match(name, Pattern ) then
GroupFound = group
break
end
end
return GroupFound
end
--- Find all UNIT objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
-- @param #UNIT self
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)) for regular expressions in LUA.
-- @return #table Units Table of matching #UNIT objects found
-- @usage
-- -- Find all group with a partial group name
-- local unittable = UNIT:FindAllByMatching( "Apple" )
-- -- will return all units with "Apple" in the name
--
-- -- using a pattern
-- local unittable = UNIT:FindAllByMatching( ".%d.%d$" )
-- -- will return the all units found ending in "-1-1" to "-9-9", but not e.g. "-10-1" or "-1-10"
function UNIT:FindAllByMatching( Pattern )
local GroupsFound = {}
for name,group in pairs(_DATABASE.UNITS) do
if string.match(name, Pattern ) then
GroupsFound[#GroupsFound+1] = group
end
end
return GroupsFound
end
--- Return the name of the UNIT. --- Return the name of the UNIT.
-- @param #UNIT self -- @param #UNIT self
-- @return #string The UNIT name. -- @return #string The UNIT name.