From 8bc735288f031382b24b3c1f2e691afd0a2868cc Mon Sep 17 00:00:00 2001 From: kaltokri Date: Wed, 8 Nov 2023 17:27:04 +0100 Subject: [PATCH 1/4] Skip java.com when checking links. Seems to be blocked for GitHub --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 4e31c95b8..b1bbe8219 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -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) From 25936a526d9462b9d0a4272137008e6b48ab097e Mon Sep 17 00:00:00 2001 From: kaltokri Date: Wed, 8 Nov 2023 17:33:25 +0100 Subject: [PATCH 2/4] Fixed small typo in gh-pages.yml --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index b1bbe8219..603bbb708 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: From 72c5c2ee4dd06e6341997d848c8cd15e2be0fb91 Mon Sep 17 00:00:00 2001 From: kaltokri Date: Wed, 8 Nov 2023 17:39:19 +0100 Subject: [PATCH 3/4] Parameter has different behaviour on Windows and Linux --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 603bbb708..0e53eea58 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -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 --skip (java.com) + - run: npx linkinator https://flightcontrol-master.github.io/MOOSE/ --verbosity error --timeout 5000 --recurse --skip "(java.com)" From 5056187fb9517b1279896a5a8f96e884c59107f9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 8 Nov 2023 17:43:25 +0100 Subject: [PATCH 4/4] #GROUP #UNIT * Added `FindByMatching(Pattern)` and `FindAllByMatching(Pattern)` --- Moose Development/Moose/Wrapper/Group.lua | 60 +++++++++++++++++++++-- Moose Development/Moose/Wrapper/Unit.lua | 53 +++++++++++++++++++- 2 files changed, 109 insertions(+), 4 deletions(-) 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.