Fix opponent gauge and get rid of errors when in a ship on the ground
This commit is contained in:
parent
36fa2d654e
commit
0c516b2425
@ -176,18 +176,18 @@ function lotj.infoPanel.createOpponentStats(container)
|
||||
opponentGauge:setFontSize("12")
|
||||
|
||||
local function update()
|
||||
local opponentName = string.gsub(gmcp.Char.Enemy.name or "", "&.", "")
|
||||
-- Opponent name seems to always be empty string even when fighting, so fall back to something reasonable
|
||||
if not gmcp.Char.Enemy.name then
|
||||
opponentGauge:setValue(0, 1, "Not fighting")
|
||||
return
|
||||
end
|
||||
|
||||
local opponentName = string.gsub(gmcp.Char.Enemy.name, "&.", "")
|
||||
if opponentName == "" then
|
||||
opponentName = "Current target"
|
||||
end
|
||||
local opponentHealth = gmcp.Char.Enemy.Percent
|
||||
local opponentHealth = gmcp.Char.Enemy.percent
|
||||
local opponentHealthMax = 100
|
||||
if opponentHealth ~= nil then
|
||||
opponentGauge:setValue(opponentHealth, opponentHealthMax, opponentName.."<br>"..opponentHealth.."%")
|
||||
else
|
||||
opponentGauge:setValue(0, 1, "Not fighting")
|
||||
end
|
||||
end
|
||||
lotj.setup.registerEventHandler("gmcp.Char.Enemy", update)
|
||||
end
|
||||
|
@ -112,8 +112,7 @@ function lotj.systemMap.drawMap()
|
||||
elem:hide()
|
||||
end
|
||||
|
||||
-- We use ship max speed as a proxy for "do we have ship data at all"
|
||||
if not gmcp.Ship or not gmcp.Ship.Info or gmcp.Ship.Info.maxSpeed == nil then
|
||||
if not gmcp.Ship or not gmcp.Ship.Info or gmcp.Ship.Info.posX == nil then
|
||||
return
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user