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")
|
opponentGauge:setFontSize("12")
|
||||||
|
|
||||||
local function update()
|
local function update()
|
||||||
local opponentName = string.gsub(gmcp.Char.Enemy.name or "", "&.", "")
|
if not gmcp.Char.Enemy.name then
|
||||||
-- Opponent name seems to always be empty string even when fighting, so fall back to something reasonable
|
opponentGauge:setValue(0, 1, "Not fighting")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local opponentName = string.gsub(gmcp.Char.Enemy.name, "&.", "")
|
||||||
if opponentName == "" then
|
if opponentName == "" then
|
||||||
opponentName = "Current target"
|
opponentName = "Current target"
|
||||||
end
|
end
|
||||||
local opponentHealth = gmcp.Char.Enemy.Percent
|
local opponentHealth = gmcp.Char.Enemy.percent
|
||||||
local opponentHealthMax = 100
|
local opponentHealthMax = 100
|
||||||
if opponentHealth ~= nil then
|
|
||||||
opponentGauge:setValue(opponentHealth, opponentHealthMax, opponentName.."<br>"..opponentHealth.."%")
|
opponentGauge:setValue(opponentHealth, opponentHealthMax, opponentName.."<br>"..opponentHealth.."%")
|
||||||
else
|
|
||||||
opponentGauge:setValue(0, 1, "Not fighting")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
lotj.setup.registerEventHandler("gmcp.Char.Enemy", update)
|
lotj.setup.registerEventHandler("gmcp.Char.Enemy", update)
|
||||||
end
|
end
|
||||||
|
@ -112,8 +112,7 @@ function lotj.systemMap.drawMap()
|
|||||||
elem:hide()
|
elem:hide()
|
||||||
end
|
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.posX == nil then
|
||||||
if not gmcp.Ship or not gmcp.Ship.Info or gmcp.Ship.Info.maxSpeed == nil then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user