From d857e3acada556bfd8e28777ac8cd8341bf38a9d Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 14 Nov 2025 13:23:57 +0100 Subject: [PATCH] #NAVIGATION - some fixes and additions --- .../Moose/Navigation/Beacons.lua | 23 ++++++++++++++----- Moose Development/Moose/Navigation/Point.lua | 17 +++++++++++++- Moose Development/Moose/Navigation/Radios.lua | 4 ++-- Moose Development/Moose/Navigation/Towns.lua | 4 ++-- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Navigation/Beacons.lua b/Moose Development/Moose/Navigation/Beacons.lua index 9c7acba8b..00b5cb852 100644 --- a/Moose Development/Moose/Navigation/Beacons.lua +++ b/Moose Development/Moose/Navigation/Beacons.lua @@ -39,7 +39,7 @@ -- -- # The BEACONS Concept -- --- This class is desinged to make information about beacons of a map/theatre easier accessible. The information contains location, type and frequencies of all or specific beacons of the map. +-- This class is designed to make information about beacons of a map/theatre easier accessible. The information contains location, type and frequencies of all or specific beacons of the map. -- -- **Note** that try to avoid hard coding stuff in Moose since DCS is updated frequently and things change. Therefore, the main source of information is either a file `beacons.lua` that can be -- found in the installation directory of DCS for each map or a table that the user needs to provide. @@ -104,7 +104,7 @@ BEACONS.version="0.1.0" -- Constructor(s) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Create a new BECAONS class instance from a given table. +--- Create a new BEACONS class instance from a given table. -- @param #BEACONS self -- @param #table BeaconTable Table with beacon info. -- @return #BEACONS self @@ -159,7 +159,7 @@ function BEACONS:NewFromTable(BeaconTable) end ---- Create a new BECAONS class instance from a given file. +--- Create a new BEACONS class instance from a given file. -- @param #BEACONS self -- @param #string FileName Full path to the file containing the map beacons. -- @return #BEACONS self @@ -267,16 +267,27 @@ end --- Get table of all beacons, optionally of a given type. -- @param #BEACONS self --- @param #number TypeID (Optional) Only return specific beacon types, *e.g.* `BEACON.Type.TACAN`. +-- @param #number TypeID (Optional) Only return specific beacon types, *e.g.* `BEACON.Type.TACAN`. Can be handed in as tanle of beacon types. -- @return #table Table of beacons. Each element is of type #BEACON.Beacon. function BEACONS:GetBeacons(TypeID) - + local beacons={} + local keys = {} + if TypeID~=nil and type(TypeID) ~= "table" then + TypeID = {TypeID} + end + + for _,_typeid in pairs(TypeID or {}) do + if _typeid ~= nil then + keys[_typeid] = _typeid + end + end + for _,_beacon in pairs(self.beacons) do local bc=_beacon --#BEACONS.Beacon - if TypeID==nil or TypeID==bc.type then + if TypeID==nil or keys[bc.type] ~= nil then table.insert(beacons, bc) end diff --git a/Moose Development/Moose/Navigation/Point.lua b/Moose Development/Moose/Navigation/Point.lua index 2c8d1e378..963e8cd05 100644 --- a/Moose Development/Moose/Navigation/Point.lua +++ b/Moose Development/Moose/Navigation/Point.lua @@ -231,6 +231,21 @@ function NAVFIX:NewFromNavFix(Name, Type, NavFix, Distance, Bearing, Reciprocal) return self end +--- Create a new NAVFIX class instance from BEACONS.Beacon data. +-- @param #NAVFIX self +-- @param Navigation.Beacons#BEACONS.Beacon Beacon The beacon data. +-- @return #NAVFIX self +function NAVFIX:NewFromBeacon(Beacon) + local frequency, unit = BEACONS:_GetFrequency(Beacon.frequency) + frequency = string.format("%.3f",frequency) + if Beacon.typeName == "TACAN" then + frequency = Beacon.channel + unit = "X" + end + self = NAVFIX:NewFromVector(string.format("%s %s %s",Beacon.typeName,frequency,unit),Beacon.typeName,Beacon.vec3) + return self +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- User Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -348,7 +363,7 @@ end --- Set whether this fix is compulsory. -- @param #NAVFIX self --- @param #boolean Compulsory If `true`, this is a compusory fix. If `false` or nil, it is non-compulsory. +-- @param #boolean Compulsory If `true`, this is a compulsory fix. If `false` or nil, it is non-compulsory. -- @return #NAVFIX self function NAVFIX:SetCompulsory(Compulsory) self.isCompulsory=Compulsory diff --git a/Moose Development/Moose/Navigation/Radios.lua b/Moose Development/Moose/Navigation/Radios.lua index 910235109..531309fc2 100644 --- a/Moose Development/Moose/Navigation/Radios.lua +++ b/Moose Development/Moose/Navigation/Radios.lua @@ -39,7 +39,7 @@ -- -- # The RADIOS Concept -- --- This class is desinged to make information about radios of a map/theatre easier accessible. The information contains mostly the frequencies of airbases of the map. +-- This class is designed to make information about radios of a map/theatre easier accessible. The information contains mostly the frequencies of airbases of the map. -- -- **Note** that try to avoid hard coding stuff in Moose since DCS is updated frequently and things change. Therefore, the main source of information is either a file `radio.lua` that can be -- found in the installation directory of DCS for each map or a table that the user needs to provide. @@ -48,7 +48,7 @@ -- -- A new `RADIOS` object can be created with the @{#RADIOS.NewFromFile}(*radio_lua_file*) function. -- --- local radios=RADIOS:NewFromFile("\Mods\terrains\\radios.lua") +-- local radios=RADIOS:NewFromFile("\Mods\terrains\\radio.lua") -- radios:MarkerShow() -- -- This will load the radios from the `` for the specific map and place markers on the F10 map. This is the first step you should do to ensure that the file diff --git a/Moose Development/Moose/Navigation/Towns.lua b/Moose Development/Moose/Navigation/Towns.lua index c5f67efbd..5f8ef2619 100644 --- a/Moose Development/Moose/Navigation/Towns.lua +++ b/Moose Development/Moose/Navigation/Towns.lua @@ -39,7 +39,7 @@ -- -- # The TOWNS Concept -- --- This class is desinged to make information about towns of a map/theatre easier accessible. The information contains location and road/rail connections of the towns. +-- This class is designed to make information about towns of a map/theatre easier accessible. The information contains location and road/rail connections of the towns. -- -- **Note** that try to avoid hard coding stuff in Moose since DCS is updated frequently and things change. Therefore, the main source of information is either a file `towns.lua` that can be -- found in the installation directory of DCS for each map or a table that the user needs to provide. @@ -48,7 +48,7 @@ -- -- A new `TOWNS` object can be created with the @{#TOWNS.NewFromFile}(*towns_lua_file*) function. -- --- local towns=TOWNS:NewFromFile("\Mods\terrains\\towns.lua") +-- local towns=TOWNS:NewFromFile("\Mods\terrains\\map\towns.lua") -- towns:MarkerShow() -- -- This will load the towns from the `` for the specific map and place markers on the F10 map. This is the first step you should do to ensure that the file