-- cache setting
local enable_damage = core.settings:get_bool("enable_damage")
-local health_bar_definition =
-{
+local health_bar_definition = {
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
text = "heart.png",
offset = { x=(-10*24)-25, y=-(48+24+16)},
}
-local breath_bar_definition =
-{
+local breath_bar_definition = {
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
text = "bubble.png",
local current = player["get_" .. field](player)
local nominal = core["PLAYER_MAX_".. field:upper() .. "_DEFAULT"]
local max_display = math.max(nominal,
- math.max(player:get_properties()[field .. "_max"], current))
- return current / max_display * nominal
+ math.max(player:get_properties()[field .. "_max"], current))
+ return current / max_display * nominal
end
local function update_builtin_statbars(player)
local immortal = player:get_armor_groups().immortal == 1
if flags.healthbar and enable_damage and not immortal then
local number = scaleToDefault(player, "hp")
- if hud.id_healthbar == nil then
- local hud_def = table.copy(health_bar_definition)
+ if hud.id_healthbar == nil then
+ local hud_def = table.copy(health_bar_definition)
hud_def.number = number
hud.id_healthbar = player:hud_add(hud_def)
else
player:get_breath() < breath_max then
local number = 2 * scaleToDefault(player, "breath")
if hud.id_breathbar == nil then
- local hud_def = table.copy(breath_bar_definition)
+ local hud_def = table.copy(breath_bar_definition)
hud_def.number = number
hud.id_breathbar = player:hud_add(hud_def)
else
return false
end
-function core.hud_replace_builtin(name, definition)
+function core.hud_replace_builtin(hud_name, definition)
if type(definition) ~= "table" or
definition.hud_elem_type ~= "statbar" then
return false
end
- if name == "health" then
+ if hud_name == "health" then
health_bar_definition = definition
for name, ids in pairs(hud_ids) do
return true
end
- if name == "breath" then
+ if hud_name == "breath" then
breath_bar_definition = definition
for name, ids in pairs(hud_ids) do