Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3adf2faa4a | ||
|
|
47e947c80e | ||
|
|
c42a61c2df | ||
|
|
ca85b0116f | ||
|
|
7f3a1d00a7 | ||
|
|
06fb098b49 | ||
|
|
49eac0a7ed | ||
|
|
fb5ea45a4d | ||
|
|
7ec3006a7e | ||
|
|
9d55f7e017 | ||
|
|
20ef08e16c | ||
|
|
cb05bd0925 | ||
|
|
3e600ead0d | ||
|
|
f30c1a25fb | ||
|
|
8a9718798d | ||
|
|
dd265920cc | ||
|
|
1b8d6154c1 | ||
|
|
ebdc7b898b | ||
|
|
4157c172f1 | ||
|
|
092d24d24a |
Binary file not shown.
@@ -15,7 +15,7 @@ AARTanker = {
|
||||
TACAN_Mode = 'X',
|
||||
|
||||
Alt = 10000/3.28,
|
||||
Speed = 250/1.944,
|
||||
Speed = 270/1.944,
|
||||
},
|
||||
|
||||
['KC135_High'] = {
|
||||
@@ -30,7 +30,7 @@ AARTanker = {
|
||||
TACAN_Mode = 'X',
|
||||
|
||||
Alt = 16000/3.28,
|
||||
Speed = 340/1.944,
|
||||
Speed = 270/1.944,
|
||||
},
|
||||
|
||||
['KC135MPRS'] = {
|
||||
@@ -45,7 +45,7 @@ AARTanker = {
|
||||
TACAN_Mode = 'X',
|
||||
|
||||
Alt = 14000/3.28,
|
||||
Speed = 340/1.944,
|
||||
Speed = 270/1.944,
|
||||
},
|
||||
|
||||
['KC130'] = {
|
||||
@@ -60,7 +60,7 @@ AARTanker = {
|
||||
TACAN_Mode = 'X',
|
||||
|
||||
Alt = 11000/3.28,
|
||||
Speed = 350/1.944,
|
||||
Speed = 270/1.944,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
+54
-12
@@ -132,9 +132,12 @@ do
|
||||
return
|
||||
end
|
||||
|
||||
self.carrierUnit = Unit.getByName(carrierUnitName)
|
||||
local obj = Utils.deepCopy(self)
|
||||
-- local obj = {}
|
||||
|
||||
if not self.carrierUnit then
|
||||
obj.carrierUnit = Unit.getByName(carrierUnitName)
|
||||
|
||||
if not obj.carrierUnit then
|
||||
local errMsg = 'ERROR: Carrier unit %s is not found in mission.'
|
||||
errMsg = string.format(Localizations:translate(errMsg,'cn'),carrierUnitName)
|
||||
|
||||
@@ -143,14 +146,29 @@ do
|
||||
return nil
|
||||
end
|
||||
|
||||
self:setMorse()
|
||||
self:setTACAN()
|
||||
self:setICLS()
|
||||
self:setLink4()
|
||||
self:setACLS(true)
|
||||
self:setATC()
|
||||
-- setmetatable(obj,self)
|
||||
-- self.__index = self
|
||||
|
||||
return self
|
||||
timer.scheduleFunction(function (vars, time)
|
||||
local carrier = vars.context
|
||||
carrier:InitBeacons()
|
||||
|
||||
return time+20
|
||||
end,{context = obj},timer.getTime()+5)
|
||||
|
||||
-- timer.scheduleFunction(function (vars)
|
||||
-- local carrier = vars.context
|
||||
-- carrier:setTACAN()
|
||||
-- carrier:setICLS()
|
||||
-- end,{context = obj},timer.getTime()+20)
|
||||
|
||||
-- obj:setMorse()
|
||||
-- obj:setLink4()
|
||||
-- obj:setATC()
|
||||
-- obj:setTACAN()
|
||||
|
||||
env.info('BAirboss - New Carrier: '..carrierUnitName)
|
||||
return obj
|
||||
end
|
||||
|
||||
function BAirboss.findClearPath(from,heading,range)
|
||||
@@ -216,7 +234,7 @@ do
|
||||
|
||||
--Calculate wind speed on runway in knots. If wind speed < 25 knots, try to make it 25 knots on deck.
|
||||
if windSpeed <= 20/1.944 then
|
||||
carrierSpeed = 25/1.944-windSpeed
|
||||
carrierSpeed = 20/1.944-windSpeed
|
||||
end
|
||||
|
||||
-- Find available waypoint and path.
|
||||
@@ -359,7 +377,10 @@ do
|
||||
type = 4,
|
||||
system = 3,
|
||||
callsign = self.Morse,
|
||||
frequency = Utils.TACANToFrequency(self.TACAN, self.TACAN_Mode)
|
||||
frequency = Utils.TACANToFrequency(self.TACAN, self.TACAN_Mode),
|
||||
channel = Channel,
|
||||
bearing = true,
|
||||
modeChannel = Mode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +466,23 @@ do
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function BAirboss:InitBeacons()
|
||||
|
||||
self:setMorse()
|
||||
self:setICLS()
|
||||
self:setLink4()
|
||||
self:setACLS(true)
|
||||
self:setTACAN()
|
||||
self:setATC()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -454,4 +492,8 @@ Airboss_Roosevelt:turnIntoWind()
|
||||
local Airboss_Sten = BAirboss:New('John C. Stennis')
|
||||
Airboss_Sten:turnIntoWind()
|
||||
|
||||
trigger.action.outText('Start',20)
|
||||
Utils.Debug("Airboss_Roosevelt: "..Airboss_Roosevelt.carrierUnit:getName())
|
||||
|
||||
Utils.Debug("Airboss_Sten: "..Airboss_Sten.carrierUnit:getName())
|
||||
|
||||
trigger.action.outText('Start BAirboss',10)
|
||||
@@ -43,7 +43,15 @@ Localizations = {
|
||||
['Auto Respawn Targets: On'] = 'Auto Respawn Targets: On',
|
||||
['Auto Respawn Targets: Off'] = 'Auto Respawn Targets: Off',
|
||||
--Message
|
||||
['You have entered range area, you can sapwn targets through radio F10 menu.'] = 'You have entered range area, you can sapwn targets through radio F10 menu.',
|
||||
['You have left rang area.'] = 'You have left rang area.',
|
||||
['There is no range section of %s left.'] = 'There is no range section of %s left.',
|
||||
['Spawn target at %s section area. targetType: %s state: %s'] = 'Spawn target at %s section area. targetType: %s state: %s',
|
||||
['Spawn target at %s section area. targetType: %s AAType: %s state: %s'] = 'Spawn target at %s section area. targetType: %s AAType: %s state: %s',
|
||||
['Your targets are spawned at: '] = 'Your targets are spawned at: ',
|
||||
['and moving to: '] = 'and moving to: ',
|
||||
['Stationary'] = 'Stationary',
|
||||
['Moving'] = 'Moving',
|
||||
},
|
||||
|
||||
--中文
|
||||
@@ -88,7 +96,15 @@ Localizations = {
|
||||
['Auto Respawn Targets: On'] = '目标自动重生: 开',
|
||||
['Auto Respawn Targets: Off'] = '目标自动重生: 关',
|
||||
--Message
|
||||
['You have entered range area, you can sapwn targets through radio F10 menu.'] = '你已经进入靶场区域, 可以通过无线电F10菜单选择生成目标.',
|
||||
['You have left rang area.'] = '你已经离开靶场区域.',
|
||||
['There is no range section of %s left.'] = '没有 %s 类型靶场空闲了.',
|
||||
['Spawn target at %s section area. targetType: %s state: %s'] = '在 %s 区域刷新目标. 目标类型: %s 状态: %s',
|
||||
['Spawn target at %s section area. targetType: %s AAType: %s state: %s'] = '在 %s 区域 刷新目标. 目标类型: %s 防空类型: %s 状态: %s',
|
||||
['Your targets are spawned at: '] = '你的目标刷新在: ',
|
||||
['and moving to: '] = '并且将要移动到: ',
|
||||
['Stationary'] = '静止目标',
|
||||
['Moving'] = '运动目标',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+88
-56
@@ -1,9 +1,12 @@
|
||||
--[[
|
||||
24.13.31.1714
|
||||
TODO:
|
||||
- finish Range:activeTartgets()
|
||||
- finish Range:activeTartgets() done
|
||||
- add function Range:addTargetPreset(group/groupName,targetType) done
|
||||
- add function Range:RemoveTargetPreset(group/groupName,targetType)
|
||||
- add function Range:RemoveTargetPreset(group/groupName,targetType) done
|
||||
|
||||
TODO: 25.1.2.1941
|
||||
- Test bugs for Range. Current: spawning and refreshing and autoRespawn are working fine.
|
||||
]]
|
||||
|
||||
|
||||
@@ -53,10 +56,16 @@ do
|
||||
return
|
||||
end
|
||||
|
||||
local self = Utils.deepCopy(self)
|
||||
|
||||
self.name = zoneName
|
||||
self.points = points
|
||||
|
||||
Utils.drawPolygon(-1,Utils.getMarkID(),points,{0,1,1,1},{0,1,0,0},2)
|
||||
local dangerZonePoints = Utils.getWayPoints(zoneName..'-1')
|
||||
if dangerZonePoints then
|
||||
Utils.drawPolygon(-1,Utils.getMarkID(),dangerZonePoints,{1,0,0,1},{1,0,0,0},2)
|
||||
end
|
||||
|
||||
for type, value in pairs(self.sectionTypes) do
|
||||
for j=1,100,1 do
|
||||
@@ -68,7 +77,7 @@ do
|
||||
end
|
||||
|
||||
--Debug
|
||||
self.drawPolygon(points)
|
||||
-- self.drawPolygon(points)
|
||||
-- trigger.action.textToAll(-1,Utils.getMarkID(),Utils.makeVec3(points[1]),{1,1,1,1},{0,0,0,0},8,false,sectionName)
|
||||
|
||||
local sectionData = {
|
||||
@@ -115,6 +124,9 @@ do
|
||||
self.removePlayerProfile(playerName)
|
||||
end
|
||||
end
|
||||
if not playerUnit then
|
||||
self.removePlayerProfile(playerName)
|
||||
end
|
||||
|
||||
if data.activeTarget then
|
||||
if data.activeTarget:isExist() then
|
||||
@@ -156,28 +168,27 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Utils.Debug(mist.utils.tableShow(self.playerList))
|
||||
--Debug
|
||||
for sectionType,sections in pairs(self.sections) do
|
||||
for i, section in ipairs(sections) do
|
||||
local text = 'not active'
|
||||
if section.active then
|
||||
text = 'active'
|
||||
end
|
||||
-- --Debug
|
||||
-- for sectionType,sections in pairs(self.sections) do
|
||||
-- for i, section in ipairs(sections) do
|
||||
-- local text = 'not active'
|
||||
-- if section.active then
|
||||
-- text = 'active'
|
||||
-- end
|
||||
|
||||
local point = {
|
||||
x = section.points[1].x,
|
||||
y = 0,
|
||||
z = section.points[1].y,
|
||||
}
|
||||
if not section.tagID then
|
||||
section.tagID = Utils.getMarkID()
|
||||
trigger.action.textToAll(-1,section.tagID,point,{1,1,0,1},{0,0,0,0},12,false,text)
|
||||
end
|
||||
-- local point = {
|
||||
-- x = section.points[1].x,
|
||||
-- y = 0,
|
||||
-- z = section.points[1].y,
|
||||
-- }
|
||||
-- if not section.tagID then
|
||||
-- section.tagID = Utils.getMarkID()
|
||||
-- trigger.action.textToAll(-1,section.tagID,point,{1,1,0,1},{0,0,0,0},12,false,text)
|
||||
-- end
|
||||
|
||||
trigger.action.setMarkupText(section.tagID,text)
|
||||
end
|
||||
end
|
||||
-- trigger.action.setMarkupText(section.tagID,text)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
return time+repeatTime
|
||||
@@ -212,13 +223,11 @@ do
|
||||
local playerName = playerUnit:getPlayerName()
|
||||
if self.playerList[playerName] then
|
||||
if self.playerList[playerName].menu then
|
||||
Utils.Debug('removeMenu')
|
||||
missionCommands.removeItemForGroup(groupID,self.playerList[playerName].menu)
|
||||
self.playerList[playerName].menu = nil
|
||||
end
|
||||
end
|
||||
|
||||
Utils.Debug('createMenu')
|
||||
local MainMenuName = Localizations:translate('Range','cn')
|
||||
local menu = missionCommands.addSubMenuForGroup(groupID,MainMenuName)
|
||||
|
||||
@@ -271,8 +280,8 @@ do
|
||||
|
||||
if self.playerList[playerName] then
|
||||
if self.playerList[playerName].targetData then
|
||||
local refreshMenuName = Localizations:translate('Refresh targets','cn')
|
||||
missionCommands.addCommandForGroup(groupID,refreshMenuName,MainMenuName,function (vars)
|
||||
local refreshMenuName = string.format('[%s]',Localizations:translate('Refresh targets','cn'))
|
||||
missionCommands.addCommandForGroup(groupID,refreshMenuName,menu,function (vars)
|
||||
local self = vars.context
|
||||
local targetData = self.playerList[playerName].targetData
|
||||
self:activeTartgets(vars.playerName,targetData.sectionType,targetData.targetType,targetData.AAType,targetData.isMove)
|
||||
@@ -284,7 +293,7 @@ do
|
||||
if self.playerList[playerName].isTargerRedAlert then
|
||||
switch = 'On'
|
||||
end
|
||||
Utils.Debug('switch: '..switch)
|
||||
|
||||
local SettingsMenuName = Localizations:translate('Settings','cn')
|
||||
local SettingsMenu = missionCommands.addSubMenuForGroup(groupID,SettingsMenuName,menu)
|
||||
|
||||
@@ -298,7 +307,6 @@ do
|
||||
if self.playerList[playerName].autoRespawn then
|
||||
switch = 'On'
|
||||
end
|
||||
Utils.Debug('switch: '..switch)
|
||||
local AutoRespawnSwitchName = Localizations:translate(string.format('Auto Respawn Targets: %s',switch),'cn')
|
||||
missionCommands.addCommandForGroup(groupID,AutoRespawnSwitchName,SettingsMenu,function (vars)
|
||||
local self = vars.context
|
||||
@@ -319,8 +327,6 @@ do
|
||||
local playerGroup = playerUnit:getGroup()
|
||||
if not playerGroup then return end
|
||||
|
||||
Utils.Debug('createPlayerProfile')
|
||||
|
||||
self.playerList[PlayerName] = {
|
||||
group = playerGroup,
|
||||
groupID = playerGroup:getID(),
|
||||
@@ -332,6 +338,9 @@ do
|
||||
menu = nil,
|
||||
}
|
||||
self:createMenu(playerGroup)
|
||||
|
||||
local enterText = Localizations:translate('You have entered range area, you can sapwn targets through radio F10 menu.','cn')
|
||||
trigger.action.outTextForGroup(playerGroup:getID(),enterText,10)
|
||||
end
|
||||
|
||||
function Range:removePlayerProfile(playerName)
|
||||
@@ -343,6 +352,12 @@ do
|
||||
missionCommands.removeItemForGroup(self.playerList[playerName].groupID,self.playerList[playerName].menu)
|
||||
|
||||
self.playerList[playerName] = nil
|
||||
|
||||
-- local leaveText = Localizations:translate('You have left rang area.','cn')
|
||||
|
||||
-- if self.playerList[playerName].group:isExist() then
|
||||
-- trigger.action.outTextForGroup(self.playerList[playerName].groupID,leaveText,10)
|
||||
-- end
|
||||
end
|
||||
|
||||
function Range:activeTartgets(playerName,sectionType,targetType,AAType,Move)
|
||||
@@ -354,15 +369,22 @@ do
|
||||
|
||||
self:deactivateTargets(playerName)
|
||||
|
||||
--Debug
|
||||
local isMove = 'Stationary'
|
||||
--Send message
|
||||
local isMove = Localizations:translate('Stationary','cn')
|
||||
if Move then
|
||||
isMove = 'Moving'
|
||||
isMove = Localizations:translate('Moving','cn')
|
||||
end
|
||||
|
||||
--Debug
|
||||
local tAAtype = AAType or 'None'
|
||||
Utils.Debug('section:'..sectionType..' targetType: '..targetType..' AAType: '..tAAtype..' Move: '..isMove)
|
||||
local baseText = Localizations:translate('Spawn target at %s section area. targetType: %s state: %s','cn')
|
||||
local tSectionType = Localizations:translate(sectionType,'cn')
|
||||
local ttargetType = Localizations:translate(targetType,'cn')
|
||||
local messageText = string.format(baseText,tSectionType,ttargetType,isMove)
|
||||
if AAType then
|
||||
baseText = Localizations:translate('Spawn target at %s section area. targetType: %s AAType: %s state: %s','cn')
|
||||
local tAAtype = Localizations:translate(AAType,'cn')
|
||||
messageText = string.format(baseText,tSectionType,ttargetType,tAAtype,isMove)
|
||||
end
|
||||
trigger.action.outTextForGroup(self.playerList[playerName].groupID,messageText,10)
|
||||
|
||||
--Get sectionZone
|
||||
local sectionZone = self.playerList[playerName].assignedSection or nil
|
||||
@@ -374,7 +396,6 @@ do
|
||||
|
||||
if not Move then
|
||||
self.sections[sectionType][zoneNum].active = true
|
||||
Utils.Debug('Active: '..self.sections[sectionType][zoneNum].name)
|
||||
end
|
||||
|
||||
break
|
||||
@@ -388,7 +409,6 @@ do
|
||||
|
||||
if not Move then
|
||||
self.sections[sectionType][i].active = true
|
||||
Utils.Debug('Active: '..self.sections[sectionType][i].name)
|
||||
end
|
||||
|
||||
break
|
||||
@@ -397,7 +417,7 @@ do
|
||||
end
|
||||
|
||||
if not sectionZone then
|
||||
trigger.action.outTextForGroup(string.format(Localizations:translate('There is no range section of %s left.','cn'),Localizations:translate(sectionType,'cn')))
|
||||
trigger.action.outTextForGroup(string.format(Localizations:translate('There is no range section of %s left.','cn'),Localizations:translate(sectionType,'cn')),10)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -409,7 +429,6 @@ do
|
||||
}
|
||||
-- self.playerList[playerName].assignedSection = sectionZone.name
|
||||
self.playerList[playerName].assignedSection = sectionZone
|
||||
Utils.Debug('assignedSection: '..sectionZone.name)
|
||||
end
|
||||
|
||||
--Get targets(typeNames)
|
||||
@@ -423,7 +442,6 @@ do
|
||||
if AAType then
|
||||
targetList = self.targetPresets[targetType][AAType]
|
||||
end
|
||||
Utils.Debug('targetType: '..targetType)
|
||||
|
||||
for i=1,6,1 do
|
||||
local randomNum = math.random(1,#targetList)
|
||||
@@ -454,9 +472,11 @@ do
|
||||
for k=2,#groupData.units,1 do
|
||||
local tDir = math.random(0,359)
|
||||
local spawnPoint = {}
|
||||
spawnPoint.x = centerPoint.x+200
|
||||
spawnPoint.y = centerPoint.z or centerPoint.y
|
||||
|
||||
for i=1,100,1 do
|
||||
local tPoint = Utils.vecTranslate(centerPoint,tDir,math.random(10,150))
|
||||
local tPoint = Utils.vecTranslate(centerPoint,tDir,math.random(100,1000)) --Spawn range
|
||||
if Utils.pointInPolygon(tPoint,sectionZone.points) then
|
||||
if land.getSurfaceType(tPoint) ~= land.SurfaceType.WATER or land.getSurfaceType(tPoint) ~= land.SurfaceType.SHALLOW_WATER then
|
||||
spawnPoint = tPoint
|
||||
@@ -465,11 +485,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
if not spawnPoint then
|
||||
spawnPoint.x = centerPoint.x+50
|
||||
spawnPoint.y = centerPoint.z+50 or centerPoint.y+50
|
||||
end
|
||||
|
||||
groupData.units[k].x = spawnPoint.x
|
||||
groupData.units[k].y = spawnPoint.z or spawnPoint.y
|
||||
end
|
||||
@@ -483,6 +498,7 @@ do
|
||||
local Controller = targetGroup:getController()
|
||||
if not Controller then return end
|
||||
|
||||
local targetPointReport = Localizations:translate('Your targets are spawned at: ','cn')
|
||||
--Set Moving
|
||||
if Move then
|
||||
local startPoint = {}
|
||||
@@ -535,11 +551,35 @@ do
|
||||
},
|
||||
}
|
||||
|
||||
local lat, lon, alt = coord.LOtoLL({x=startPoint.x,y=land.getHeight(startPoint),z=startPoint.y})
|
||||
local grid = coord.LLtoMGRS(lat,lon)
|
||||
local LLText = Utils.tostringLL(lat,lon,3)
|
||||
local MGRSText = grid.UTMZone .. ' ' .. grid.MGRSDigraph .. ' ' .. grid.Easting .. ' ' .. grid.Northing
|
||||
targetPointReport = targetPointReport.. '\nLLDM: '..LLText..' \nMGRS: '..MGRSText
|
||||
|
||||
targetPointReport = targetPointReport ..'\n'.. Localizations:translate('and moving to: ','cn')
|
||||
|
||||
lat, lon, alt = coord.LOtoLL({x=finPoint.x,y=land.getHeight(finPoint),z=finPoint.y})
|
||||
grid = coord.LLtoMGRS(lat,lon)
|
||||
LLText = Utils.tostringLL(lat,lon,3,true)
|
||||
MGRSText = grid.UTMZone .. ' ' .. grid.MGRSDigraph .. ' ' .. grid.Easting .. ' ' .. grid.Northing
|
||||
targetPointReport = targetPointReport.. '\nLLDM: '..LLText..' \nMGRS: '..MGRSText
|
||||
|
||||
timer.scheduleFunction(function (Mission)
|
||||
Controller:setTask(Mission)
|
||||
end,Mission,timer.getTime()+5)
|
||||
end
|
||||
|
||||
if not Move then
|
||||
local lat, lon, alt = coord.LOtoLL({x=centerPoint.x,y=land.getHeight(centerPoint),z=centerPoint.y})
|
||||
local grid = coord.LLtoMGRS(lat,lon)
|
||||
local LLText = Utils.tostringLL(lat,lon,3)
|
||||
local MGRSText = grid.UTMZone .. ' ' .. grid.MGRSDigraph .. ' ' .. grid.Easting .. ' ' .. grid.Northing
|
||||
targetPointReport = targetPointReport.. '\nLLDM: '..LLText..' \nMGRS: '..MGRSText
|
||||
end
|
||||
|
||||
trigger.action.outTextForGroup(self.playerList[playerName].groupID,targetPointReport,60)
|
||||
|
||||
--Set fight back
|
||||
if self.playerList[playerName].isTargerRedAlert then
|
||||
timer.scheduleFunction(function (targetGroup)
|
||||
@@ -566,7 +606,6 @@ do
|
||||
self.playerList[PlayerName].activeTarget = nil
|
||||
|
||||
self.playerList[PlayerName].assignedSection.active = false
|
||||
|
||||
end
|
||||
|
||||
function Range:addTargetPreset(groupIdent,targetType,AAtype)
|
||||
@@ -600,9 +639,6 @@ do
|
||||
AAtype = Range.AATypes.AAA
|
||||
end
|
||||
end
|
||||
-- Utils.Debug('typeName: '..targetDesc['typeName'])
|
||||
-- Utils.Debug(' AAtype: '..AAtype)
|
||||
-- Utils.Debug(targetDesc.attributes)
|
||||
|
||||
self.targetPresets[targetType] = self.targetPresets[targetType] or {}
|
||||
self.targetPresets[targetType][AAtype] = self.targetPresets[targetType][AAtype] or {}
|
||||
@@ -711,14 +747,10 @@ do
|
||||
for i=1,20,1 do
|
||||
local unit = Unit.getByName('test-'..i..'-1')
|
||||
if unit then
|
||||
-- local desc = unit:getDesc()
|
||||
-- Utils.Debug(desc['typeName']..' desc:')
|
||||
-- Utils.Debug(desc.attributes)
|
||||
range1:addTargetPreset(unit)
|
||||
end
|
||||
end
|
||||
|
||||
-- Utils.Debug(range1.targetPresets)
|
||||
end
|
||||
|
||||
-- local group = Group.getByName('Buta_target')
|
||||
|
||||
@@ -275,7 +275,104 @@ do
|
||||
return newCoord
|
||||
end
|
||||
|
||||
--- Simple rounding function.
|
||||
-- From http://lua-users.org/wiki/SimpleRound
|
||||
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
|
||||
-- @tparam number num number to round
|
||||
-- @param idp
|
||||
function Utils.round(num, idp)
|
||||
local mult = 10^(idp or 0)
|
||||
return math.floor(num * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
--[[acc:
|
||||
in DM: decimal point of minutes.
|
||||
In DMS: decimal point of seconds.
|
||||
position after the decimal of the least significant digit:
|
||||
So:
|
||||
42.32 - acc of 2.
|
||||
]]
|
||||
function Utils.tostringLL(lat, lon, acc, DMS)
|
||||
|
||||
local latHemi, lonHemi
|
||||
if lat > 0 then
|
||||
latHemi = 'N'
|
||||
else
|
||||
latHemi = 'S'
|
||||
end
|
||||
|
||||
if lon > 0 then
|
||||
lonHemi = 'E'
|
||||
else
|
||||
lonHemi = 'W'
|
||||
end
|
||||
|
||||
lat = math.abs(lat)
|
||||
lon = math.abs(lon)
|
||||
|
||||
local latDeg = math.floor(lat)
|
||||
local latMin = (lat - latDeg)*60
|
||||
|
||||
local lonDeg = math.floor(lon)
|
||||
local lonMin = (lon - lonDeg)*60
|
||||
|
||||
if DMS then -- degrees, minutes, and seconds.
|
||||
local oldLatMin = latMin
|
||||
latMin = math.floor(latMin)
|
||||
local latSec = Utils.round((oldLatMin - latMin)*60, acc)
|
||||
|
||||
local oldLonMin = lonMin
|
||||
lonMin = math.floor(lonMin)
|
||||
local lonSec = Utils.round((oldLonMin - lonMin)*60, acc)
|
||||
|
||||
if latSec == 60 then
|
||||
latSec = 0
|
||||
latMin = latMin + 1
|
||||
end
|
||||
|
||||
if lonSec == 60 then
|
||||
lonSec = 0
|
||||
lonMin = lonMin + 1
|
||||
end
|
||||
|
||||
local secFrmtStr -- create the formatting string for the seconds place
|
||||
if acc <= 0 then -- no decimal place.
|
||||
secFrmtStr = '%02d'
|
||||
else
|
||||
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
|
||||
secFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||
end
|
||||
|
||||
return string.format('%02d', latDeg) .. ' ' .. string.format('%02d', latMin) .. '\' ' .. string.format(secFrmtStr, latSec) .. '"' .. latHemi .. ' '
|
||||
.. string.format('%02d', lonDeg) .. ' ' .. string.format('%02d', lonMin) .. '\' ' .. string.format(secFrmtStr, lonSec) .. '"' .. lonHemi
|
||||
|
||||
else -- degrees, decimal minutes.
|
||||
latMin = Utils.round(latMin, acc)
|
||||
lonMin = Utils.round(lonMin, acc)
|
||||
|
||||
if latMin == 60 then
|
||||
latMin = 0
|
||||
latDeg = latDeg + 1
|
||||
end
|
||||
|
||||
if lonMin == 60 then
|
||||
lonMin = 0
|
||||
lonDeg = lonDeg + 1
|
||||
end
|
||||
|
||||
local minFrmtStr -- create the formatting string for the minutes place
|
||||
if acc <= 0 then -- no decimal place.
|
||||
minFrmtStr = '%02d'
|
||||
else
|
||||
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
|
||||
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||
end
|
||||
|
||||
return string.format('%02d', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' '
|
||||
.. string.format('%02d', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
--- Converts a TACAN Channel/Mode couple into a frequency in Hz.
|
||||
-- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X".
|
||||
|
||||
Reference in New Issue
Block a user