diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 4e31c95b8..0e53eea58 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -11,7 +11,7 @@ on: branches: ["master"] paths: - 'docs/**' - - '.github/workflows/pages.yml' + - '.github/workflows/gh-pages.yml' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -75,4 +75,4 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 - 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)" diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 5ac314940..2868918f4 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -31,7 +31,8 @@ -- ### Contributions: -- -- * **Entropy**, **Afinegan**: Came up with the requirement for AIOnOff(). --- +-- * **Applevangelist**: various +-- -- === -- -- @module Wrapper.Group @@ -45,12 +46,16 @@ --- Wrapper class of the DCS world Group object. -- +-- ## Finding groups +-- -- The GROUP class provides the following functions to retrieve quickly the relevant GROUP instance: -- -- * @{#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: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. -- --- # 1. Tasking of groups +-- ## Tasking of groups -- -- A GROUP is derived from the wrapper class CONTROLLABLE (@{Wrapper.Controllable#CONTROLLABLE}). -- See the @{Wrapper.Controllable} task methods section for a description of the task methods. @@ -285,7 +290,7 @@ function GROUP:Find( DCSGroup ) return GroupFound end ---- Find the created GROUP using the DCS Group Name. +--- Find a GROUP using the DCS Group Name. -- @param #GROUP self -- @param #string GroupName The DCS Group Name. -- @return #GROUP The GROUP. @@ -295,6 +300,55 @@ function GROUP:FindByName( GroupName ) return GroupFound end +--- Find the first(!) GROUP matching using patterns. Note that this is **a lot** slower than `:FindByName()`! +-- @param #GROUP 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 #GROUP The GROUP. +-- @usage +-- -- Find a group with a partial group name +-- local grp = GROUP:FindByMatching( "Apple" ) +-- -- will return e.g. a group named "Apple-1-1" +-- +-- -- using a pattern +-- local grp = GROUP:FindByMatching( ".%d.%d$" ) +-- -- will return the first group found ending in "-1-1" to "-9-9", but not e.g. "-10-1" +function GROUP:FindByMatching( Pattern ) + local GroupFound = nil + + for name,group in pairs(_DATABASE.GROUPS) do + if string.match(name, Pattern ) then + GroupFound = group + break + end + end + + return GroupFound +end + +--- Find all GROUP objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`! +-- @param #GROUP 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 Groups Table of matching #GROUP objects found +-- @usage +-- -- Find all group with a partial group name +-- local grptable = GROUP:FindAllByMatching( "Apple" ) +-- -- will return all groups with "Apple" in the name +-- +-- -- using a pattern +-- local grp = GROUP:FindAllByMatching( ".%d.%d$" ) +-- -- will return the all groups found ending in "-1-1" to "-9-9", but not e.g. "-10-1" or "-1-10" +function GROUP:FindAllByMatching( Pattern ) + local GroupsFound = {} + + for name,group in pairs(_DATABASE.GROUPS) do + if string.match(name, Pattern ) then + GroupsFound[#GroupsFound+1] = group + end + end + + return GroupsFound +end + -- DCS Group methods support. --- Returns the DCS Group. diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 0fc411ebd..e02bd374d 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -13,7 +13,7 @@ -- -- ### 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.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:FindByAllMatching}(): 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). -- @@ -160,6 +162,55 @@ function UNIT:FindByName( UnitName ) return UnitFound 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. -- @param #UNIT self -- @return #string The UNIT name.