Added displayTimeMultiplier parameter

This commit is contained in:
Ambroise Garel
2025-09-11 11:28:50 +02:00
parent 814fbccb00
commit b140238aa0
+13 -8
View File
@@ -50,7 +50,7 @@ do
end end
message = DCSEx.string.firstToUpper(message) message = DCSEx.string.firstToUpper(message)
local duration = DCSEx.string.getReadingTime(message) local duration = DCSEx.string.getReadingTime(message) * args.displayTimeMultiplier
-- Print message -- Print message
trigger.action.outTextForUnit(args.unitID, callsign:upper()..": "..message, duration, false) trigger.action.outTextForUnit(args.unitID, callsign:upper()..": "..message, duration, false)
@@ -73,12 +73,13 @@ do
-- @param delayed Should the message be delayed (used for message answers) -- @param delayed Should the message be delayed (used for message answers)
-- @param functionToRun Function to run when the message is played -- @param functionToRun Function to run when the message is played
-- @param functionParameters Parameters for the function to run when the message is played -- @param functionParameters Parameters for the function to run when the message is played
-- @param displayTimeMultiplier Multiplier for how long the message should be displayed (2.0=twice as long, 0.5=half as long). Default is 1.0
------------------------------------- -------------------------------------
function TUM.radio.playForAll(messageID, replacements, callsign, delayed, functionToRun, functionParameters) function TUM.radio.playForAll(messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
local players = DCSEx.world.getAllPlayers() local players = DCSEx.world.getAllPlayers()
for _, unit in pairs(players) do for _, unit in pairs(players) do
TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(unit), messageID, replacements, callsign, delayed, functionToRun, functionParameters) TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(unit), messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
end end
end end
@@ -91,12 +92,13 @@ do
-- @param delayed Should the message be delayed (used for message answers) -- @param delayed Should the message be delayed (used for message answers)
-- @param functionToRun Function to run when the message is played -- @param functionToRun Function to run when the message is played
-- @param functionParameters Parameters for the function to run when the message is played -- @param functionParameters Parameters for the function to run when the message is played
-- @param displayTimeMultiplier Multiplier for how long the message should be displayed (2.0=twice as long, 0.5=half as long). Default is 1.0
------------------------------------- -------------------------------------
function TUM.radio.playForCoalition(coalitionID, messageID, replacements, callsign, delayed, functionToRun, functionParameters) function TUM.radio.playForCoalition(coalitionID, messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
local players = coalition.getPlayers(coalitionID) local players = coalition.getPlayers(coalitionID)
for _,u in pairs(players) do for _,u in pairs(players) do
TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(u), messageID, replacements, callsign, delayed, functionToRun, functionParameters) TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(u), messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
end end
end end
@@ -109,13 +111,14 @@ do
-- @param delayed Should the message be delayed (used for message answers) -- @param delayed Should the message be delayed (used for message answers)
-- @param functionToRun Function to run when the message is played -- @param functionToRun Function to run when the message is played
-- @param functionParameters Parameters for the function to run when the message is played -- @param functionParameters Parameters for the function to run when the message is played
-- @param displayTimeMultiplier Multiplier for how long the message should be displayed (2.0=twice as long, 0.5=half as long). Default is 1.0
------------------------------------- -------------------------------------
function TUM.radio.playForGroup(groupID, messageID, replacements, callsign, delayed, functionToRun, functionParameters) function TUM.radio.playForGroup(groupID, messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
local group = DCSEx.world.getGroupByID(groupID) local group = DCSEx.world.getGroupByID(groupID)
if not group then return end -- group does not exist if not group then return end -- group does not exist
for _,u in pairs(group:getUnits()) do for _,u in pairs(group:getUnits()) do
TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(u), messageID, replacements, callsign, delayed, functionToRun, functionParameters) TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(u), messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
end end
end end
@@ -129,8 +132,9 @@ do
-- @param delayed Should the message be delayed (used for message answers) -- @param delayed Should the message be delayed (used for message answers)
-- @param functionToRun Function to run when the message is played -- @param functionToRun Function to run when the message is played
-- @param functionParameters Parameters for the function to run when the message is played -- @param functionParameters Parameters for the function to run when the message is played
-- @param displayTimeMultiplier Multiplier for how long the message should be displayed (2.0=twice as long, 0.5=half as long). Default is 1.0
------------------------------------- -------------------------------------
function TUM.radio.playForUnit(unitID, messageID, replacements, callsign, delayed, functionToRun, functionParameters) function TUM.radio.playForUnit(unitID, messageID, replacements, callsign, delayed, functionToRun, functionParameters, displayTimeMultiplier)
if not messageID then return end if not messageID then return end
if not Library.radioMessages[messageID] then return end if not Library.radioMessages[messageID] then return end
delayed = delayed or false delayed = delayed or false
@@ -141,6 +145,7 @@ do
local radioArgs = { local radioArgs = {
callsign = callsign, callsign = callsign,
displayTimeMultiplier = math.max(0.1, displayTimeMultiplier or 1.0),
functionToRun = functionToRun, functionToRun = functionToRun,
functionParameters = functionParameters, functionParameters = functionParameters,
messageID = messageID, messageID = messageID,