Skip to content

Commit

Permalink
Fix how hp is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWolfHT committed Dec 25, 2023
1 parent ecb3194 commit 2ee4395
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions builtin/game/statbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ local bar_definitions = {
local hud_ids = {}

local function scaleToHudMax(player, field)
-- Scale "hp" or "breath" to the hud maximum dimensions
local current = player["get_" .. field](player)
local nominal = bar_definitions[field].item
local max_display = math.max(player:get_properties()[field .. "_max"], current)
return math.ceil(current / max_display * nominal)
if field == "hp" then
return player["get" .. field](player)
else
-- Scale "hp" or "breath" to the hud maximum dimensions
local current = player["get_" .. field](player)
local nominal = bar_definitions[field].item
local max_display = math.max(player:get_properties()[field .. "_max"], current)
return math.ceil(current / max_display * nominal)
end
end

local function update_builtin_statbars(player)
Expand Down

0 comments on commit 2ee4395

Please sign in to comment.