Removed references to world.getPlayer()

This commit is contained in:
Ambroise Garel 2025-08-05 17:22:16 +02:00
parent dca67aa13c
commit c3ecc403e2
3 changed files with 12 additions and 4 deletions

View File

@ -107,7 +107,7 @@ do
end
function TUM.mission.getPlayerCallsign()
local player = world.getPlayer()
local player = DCSEx.world.getFirstPlayer(TUM.settings.getPlayerCoalition())
if player then return player:getCallsign() end
return "Flight"
end

View File

@ -138,7 +138,9 @@ do
-- "Change altitude" submenu
------------------------------------------------------
local altitudePath = missionCommands.addSubMenu("Change altitude", rootPath)
local baseAltitude = DCSEx.converter.metersToFeet(Library.aircraft[world.getPlayer():getTypeName()].altitude)
local player = DCSEx.world.getFirstPlayer(TUM.settings.getPlayerCoalition())
local baseAltitude = DCSEx.converter.metersToFeet(10000)
if player then baseAltitude = DCSEx.converter.metersToFeet(Library.aircraft[player:getTypeName()].altitude) end
local altitudeFactions = { 0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5 }
for _,f in ipairs(altitudeFactions) do
local altText = DCSEx.string.toStringThousandsSeparator(math.floor((baseAltitude * f) / 100) * 100).."ft"

View File

@ -29,7 +29,7 @@ do
end
local function getAltitude()
local player = world.getPlayer()
local player = DCSEx.world.getFirstPlayer(TUM.settings.getPlayerCoalition())
if not player then return 600 end -- Don't care about altitude if player's dead anyway
local altitude = Library.aircraft[player:getTypeName()].altitude * cruiseAltitudeFraction
@ -133,10 +133,16 @@ do
local function getRejoinTaskTable(formationDistance)
formationDistance = formationDistance or 800
local player = DCSEx.world.getFirstPlayer(TUM.settings.getPlayerCoalition())
local groupID = 1
if player then
groupID = DCSEx.dcs.getObjectIDAsNumber(player:getGroup()) or 1
end
return {
id = "Follow",
params = {
groupId = DCSEx.dcs.getObjectIDAsNumber(world.getPlayer():getGroup()),
groupId = groupID,
lastWptIndexFlag = false,
lastWptIndex = -1,
pos = { x = -formationDistance, y = 0, z = -formationDistance }