-------------------------------------------------------------------------------------------- -- __ __ ___ _ __ __ -- / //_/ / | __________(_)____/ /_____ _____ / /_ -- / ,< ______/ /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ -- / /| /_____/ ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ -- /_/ |_| ___/_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ -- / |/ /___ ______/ /_______ -- / /|_/ / __ `/ ___/ //_/ ___/ -- / / / / /_/ / / / ,< (__ ) -- /_/ /_/\__,_/_/ /_/|_/____/ -- -------------------------------------------------------------------------------------------- --v1.1 ------------------------------------ DEV NOTES --------------------------------------------- -- DONE - code improvements - better shape creation logics -- DONE - corrected bug that cause un wanted shape persistance in some cases -- DONE - COORD FUNCTION - REMOVED -- -- -- K-Assistant: Marks - allows you to get some useful informations using F10 map markers. -- -- METAR of a specific point on the map - METAR information and other useful information will be shown in the map marker text, this will be visible to coalition. -- COORDINATE DISPLAY - Marker coordinates in varius formats and ground elevation will be shown in Marker text and via message only to the group that has created the mark. -- ---------------------------------- HOW TO USE -------------------------------------------- -- -- METAR -- Add a Marker in F10 Map, edit the marker text by inserting the following tag: "#METAR" -- Click outside the text field to apply, marker text will be replaced with METAR infos then. -- METAR MARK Will be automatically removed after some time. (120 seconds by default) -- -- CIRCLES -- Add a Marker in F10 Map, edit the marker text by inserting the following tag: "#CIRCLE" -- Click outside the text field to apply, a circle draw will appear on marker. -- Delete marker to delete circle. -- You can specify circle radius in meters between brakets in marker text - e.g. " #CIRCLE (1000) " - will create a 1000 meters radius circle -- -- ARROWS -- Add a Marker in F10 Map, edit the marker text by inserting the following tag: "#ARROW" -- Click outside the text field to apply, a arrow draw will appear on marker. -- Delete marker to delete arrow. -- You can specify arrow heading between brakets in marker text - e.g. " #ARROW (270) " - will create an arrow pointing for 270 -- -- MOOSE PSEUDO ATC -- in settings you can enable Moose Pseudo ATC if you want. -- See MOOSE Framework docs form more infos about Pseudo ATC. -- -- ----------------------------------- SETTINGS --------------------------------------------- MarksSettings = { PseudoATCEnable = false, -- enables/disables MOOSE Pseudo ATC please see : https://flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Functional.PseudoATC.html MetarEnable = true, -- enables/disables METAR marks MetarTag = "#METAR", -- define metar tag , a string of text that user need to insert into mark text to generate metar infos (default #METAR) MetarMarkerRemoveTime = 120, -- time in seconds after which the metar-marker will be deleted (default 120) SignsEnable = true, -- enables/disables CIRCLE and ARROW marks CircleTag = "#CIRCLE", ArrowTag = "#ARROW", WelcomeMessage = true, -- if true a Welcome Message will be displayed at mission start } -------------------------------- END OF SETTINGS ----------------------------------------- if BASE == nil then env.info("MOOSE Framework not found! You must load MOOSE before K-Assistant!", true) end MetarMarks = {} -- table where metar markers objects will be stored ShapesMarks = {} -- table where shapes markers objects will be stored function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function Marks_ReverseBearing(bearing) if not bearing then return end bearing = tonumber(bearing) local reversedBearing = nil if bearing >= 180 then reversedBearing = bearing - 180 elseif bearing < 180 then reversedBearing = bearing + 180 end return reversedBearing end function MetarMarksGenerator (EventData) if MarksSettings.MetarEnable == false then return end local initMarkText = string.upper(EventData.MarkText) if not string.match(initMarkText, MarksSettings.MetarTag) then return end local markPoint = EventData.MarkCoordinate local initMarkID = EventData.MarkID local COALITION = EventData.MarkCoalition -- local group = EventData.IniGroup local stringCoordinateLLDMS = markPoint:ToStringLLDMS() local landHeightMeters = math.floor(markPoint:GetLandHeight()) local landHeightFeet = math.floor(UTILS.MetersToFeet(landHeightMeters)) local temperatureCelsius = math.floor(markPoint:GetTemperature(landHeightMeters + 2)) local temperatureFarenheit = math.floor(UTILS.CelsiusToFahrenheit(temperatureCelsius)) local pressurehPa = math.round(markPoint:GetPressure(landHeightMeters + 2), 2) local pressureinHg = math.round(UTILS.hPa2inHg(pressurehPa), 2) local windAtGround = { markPoint:GetWind(landHeightMeters + 2) } -- return 2 values local windFrom = math.floor(windAtGround[1]) local windSpeedMs = math.round( windAtGround[2], 1) local windSpeedKmh = math.round( UTILS.MpsToKmph(windSpeedMs), 1) local windSpeedKts = math.round( UTILS.MpsToKnots(windSpeedMs), 1) -- table containing element to compose metar mark text local textTable = { separator = "__________________________________________________\n", title = "K-Assistant METAR INFO".."\n", coordinate = stringCoordinateLLDMS, wind = "Wind from : "..windFrom.." (at ground)".."\n", windspeed = "at : "..windSpeedMs.." m/s".." | "..windSpeedKts.." kts".." | "..windSpeedKmh.." Km/h".."\n", landHeight = "Elev: "..landHeightMeters.."m".." | "..landHeightFeet.."ft".." | ", temperature = "Temp: "..temperatureCelsius.."°C".." | "..temperatureFarenheit.."°F".."\n", pressure = "QFE: "..pressurehPa.." hPa".." | "..pressureinHg.." inHg".."\n", } local metarMarkText = textTable.title..textTable.wind..textTable.windspeed..textTable.landHeight..textTable.temperature..textTable.pressure MetarMarks[initMarkID] = MARKER:New(markPoint):SetText(metarMarkText):ReadOnly():ToCoalition(COALITION) MetarMarks[initMarkID]:Remove(MarksSettings.MetarMarkerRemoveTime) -- removes metar marker after a predetermined time trigger.action.removeMark(initMarkID)-- removes initial user-created marker end function CircleAdd(EventData) if MarksSettings.SignsEnable == false then return end local iniMarkText = string.upper(EventData.MarkText) if not string.match(iniMarkText, MarksSettings.CircleTag) then return end local iniMarkID = EventData.MarkID ShapesMarks[iniMarkID] = {} local iniMarkCoordinate = EventData.MarkCoordinate local circleRadius = ( string.match(iniMarkText, "%((%d+)%)") or 1000) local COALITION = EventData.MarkCoalition trigger.action.removeMark( iniMarkID ) -- removes user created mark ShapesMarks[iniMarkID].circle = iniMarkCoordinate:CircleToAll(circleRadius, COALITION, {1, 0, 0}, 0.5, {0, 0, 1}, 0.15, 6, false, nil) -- add circle shape ShapesMarks[iniMarkID].marker = MARKER:New( iniMarkCoordinate , "DELETE TO REMOVE CIRCLE" ):ToCoalition( COALITION ) -- add script created mark ShapesMarks[iniMarkID].marker.OnAfterRemoved = function (From, Event, To, EventData) -- listen to remove event and if mark is removed... trigger.action.removeMark( ShapesMarks[iniMarkID].circle ) -- remove shape ShapesMarks[iniMarkID] = nil -- set all data to nil end end function ArrowAdd(EventData) if MarksSettings.SignsEnable == false then return end local iniMarkText = string.upper(EventData.MarkText) if not string.match(iniMarkText, MarksSettings.ArrowTag) then return end local iniMarkID = EventData.MarkID ShapesMarks[iniMarkID] = {} local iniMarkCoordinate = EventData.MarkCoordinate local arrowBRG = ( Marks_ReverseBearing(string.match(iniMarkText, "%((%d+)%)")) or 180) local arrowLenght = 1000 local endPoint = iniMarkCoordinate:Translate(arrowLenght, arrowBRG, true, false) local COALITION = EventData.MarkCoalition trigger.action.removeMark( iniMarkID ) -- removes user created mark ShapesMarks[iniMarkID].arrow = endPoint:ArrowToAll(iniMarkCoordinate, COALITION, { 1, 0, 0 }, 0.5, { 0,0,1 }, 0.15, 6, false, nil) -- add circle shape ShapesMarks[iniMarkID].marker = MARKER:New( iniMarkCoordinate , "DELETE TO REMOVE ARROW" ):ToCoalition( COALITION ) -- add script created mark ShapesMarks[iniMarkID].marker.OnAfterRemoved = function (From, Event, To, EventData) -- listen to remove event and if mark is removed... trigger.action.removeMark( ShapesMarks[iniMarkID].arrow ) -- remove shape ShapesMarks[iniMarkID] = nil -- set all data to nil end end if MarksSettings.PseudoATCEnable == true then pseudoATC=PSEUDOATC:New() pseudoATC:Start() end MarksEventHandler = EVENTHANDLER:New() --MarksEventHandler:HandleEvent(EVENTS.MarkAdded) MarksEventHandler:HandleEvent(EVENTS.MarkChange) --MarksEventHandler:HandleEvent(EVENTS.MarkRemoved) --EVENTDATA.MarkCoalition --EVENTDATA.MarkCoordinate --EVENTDATA.MarkGroupID --EVENTDATA.MarkID --EVENTDATA.MarkText --EVENTDATA.MarkVec3 --function MarksEventHandler:OnEventMarkAdded(EventData) --end function MarksEventHandler:OnEventMarkChange(EventData) MetarMarksGenerator (EventData) CircleAdd(EventData) ArrowAdd(EventData) end --function MarksEventHandler:OnEventMarkRemoved(EventData) --end env.info("K-Assistant : Marks - Loaded!", false) if MarksSettings.WelcomeMessage == true then MESSAGE:New( "K-Assistant: Marks - Loaded!" , 3):ToAll() end