mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
4b1a1cbcff
@ -3815,3 +3815,31 @@ function UTILS.LoadSetOfOpsGroups(Path,Filename)
|
||||
return datatable
|
||||
end
|
||||
|
||||
--- Get the clock position from a relative heading
|
||||
-- @param #number refHdg The heading of the reference object (such as a Wrapper.UNIT) in 0-360
|
||||
-- @param #number tgtHdg The absolute heading from the reference object to the target object/point in 0-360
|
||||
-- @return #string text Text in clock heading such as "4 O'CLOCK"
|
||||
-- @usage Display the range and clock distance of a BTR in relation to REAPER 1-1's heading:
|
||||
--
|
||||
-- myUnit = UNIT:FindByName( "REAPER 1-1" )
|
||||
-- myTarget = GROUP:FindByName( "BTR-1" )
|
||||
--
|
||||
-- coordUnit = myUnit:GetCoordinate()
|
||||
-- coordTarget = myTarget:GetCoordinate()
|
||||
--
|
||||
-- hdgUnit = myUnit:GetHeading()
|
||||
-- hdgTarget = coordUnit:HeadingTo( coordTarget )
|
||||
-- distTarget = coordUnit:Get3DDistance( coordTarget )
|
||||
--
|
||||
-- clockString = UTILS.ClockHeadingString( hdgUnit, hdgTarget )
|
||||
--
|
||||
-- -- Will show this message to REAPER 1-1 in-game: Contact BTR at 3 o'clock for 1134m!
|
||||
-- MESSAGE:New("Contact BTR at " .. clockString .. " for " .. distTarget .. "m!):ToUnit( myUnit )
|
||||
function UTILS.ClockHeadingString(refHdg,tgtHdg)
|
||||
local relativeAngle = tgtHdg - refHdg
|
||||
if relativeAngle < 0 then
|
||||
relativeAngle = relativeAngle + 360
|
||||
end
|
||||
local clockPos = math.ceil((relativeAngle % 360) / 30)
|
||||
return clockPos.." o'clock"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user