Added "Give weather report" radio command

This commit is contained in:
Ambroise Garel
2025-09-14 12:12:25 +02:00
parent 104fee86e9
commit 3af259f048
4 changed files with 28 additions and 17 deletions
+18 -6
View File
@@ -20,6 +20,13 @@ do
end
end
local function getTemperatureCelsiusAndFarenheit(temperature, inKelvins)
inKelvins = inKelvins or false
if inKelvins then temperature = temperature - 273.15 end
return tostring(math.floor(temperature)).."°C/"..tostring(math.floor(DCSEx.converter.celsiusToFahrenheit(temperature))).."°F"
end
function TUM.atc.requestNavAssistanceToObjective(index, delayRadioAnswer)
local obj = TUM.objectives.getObjective(index)
if not obj then return end
@@ -118,18 +125,23 @@ do
end
function TUM.atc.requestWeatherUpdate(delayRadioAnswer)
local weatherInfo = "- It is currenly "..DCSEx.string.getTimeString()
local commonWeatherInfo = "- It is currenly "..DCSEx.string.getTimeString()
if Library.environment.isItNightTime() then
weatherInfo = weatherInfo.." (night, sunrise at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, false))..")\n"
commonWeatherInfo = commonWeatherInfo.." (night, sunrise at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, false))..")\n"
else
weatherInfo = weatherInfo.." (day, sunset at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, true))..")\n"
commonWeatherInfo = commonWeatherInfo.." (day, sunset at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, true))..")\n"
end
weatherInfo = weatherInfo.."- Average windspeed is "..tostring(DCSEx.floor(Library.environment.getWindAverage())).."m/s\n"
local players = coalition.getPlayers(TUM.settings.getPlayerCoalition())
for _,p in ipairs(players) do
TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(p), "atcWeatherUpdate", { weatherInfo }, "Control", delayRadioAnswer)
local lTemperature, _ = atmosphere.getTemperatureAndPressure(p:getPoint())
local localWeatherInfo = "- Average windspeed is "..tostring(math.floor(Library.environment.getWindAverage())).."m/s\n"
localWeatherInfo = localWeatherInfo.."- Windspeed at your location is "..DCSEx.math.getLength3D(atmosphere.getWind(p:getPoint())).."m/s\n"
localWeatherInfo = localWeatherInfo.."- Average ground-level temperature is "..getTemperatureCelsiusAndFarenheit(env.mission.weather.season.temperature).."\n"
localWeatherInfo = localWeatherInfo.."- Temperature at your location is "..getTemperatureCelsiusAndFarenheit(lTemperature, true)
TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(p), "atcWeatherUpdate", { commonWeatherInfo..localWeatherInfo }, "Control", delayRadioAnswer)
end
end
end
+3 -3
View File
@@ -30,7 +30,7 @@ do
local function doCommandWeatherUpdate()
TUM.radio.playForCoalition(TUM.settings.getPlayerCoalition(), "playerATCWeatherUpdate", nil, TUM.mission.getPlayerCallsign(), false)
TUM.atc.requestWeatherUpdate(false)
TUM.atc.requestWeatherUpdate(true)
end
function TUM.missionMenu.create()
@@ -38,9 +38,9 @@ do
missionCommands.addCommand("☱ Mission status", rootMenu, doCommandMissionStatus, nil)
local objectivesMenuRoot = missionCommands.addSubMenu("❖ Objectives", rootMenu)
local navigationMenuRoot = missionCommands.addSubMenu("➽ Navigation", rootMenu)
missionCommands.addCommand("Nav to nearest airbase", navigationMenuRoot, doCommandNearestAirbase, nil)
for i=1,TUM.objectives.getCount() do
local obj = TUM.objectives.getObjective(i)
if obj then
@@ -51,7 +51,7 @@ do
missionCommands.addCommand("Nav to objective "..objNameAndDescription, navigationMenuRoot, doCommandObjectiveLocation, i)
end
end
-- missionCommands.addCommand("Weather update", navigationMenuRoot, doCommandWeatherUpdate, nil)
missionCommands.addCommand("Weather update", navigationMenuRoot, doCommandWeatherUpdate, nil)
TUM.wingmenMenu.create()
TUM.supportAWACS.createMenu()