Statbars.lua: Cache enable_damage setting

This commit is contained in:
tenplus1 2017-02-10 17:40:57 +00:00 committed by paramat
parent 5db41d4d21
commit e9cd7187e8

@ -1,3 +1,5 @@
-- cache setting
local enable_damage = core.setting_getbool("enable_damage") == true
local health_bar_definition = local health_bar_definition =
{ {
@ -42,8 +44,7 @@ local function initialize_builtin_statbars(player)
player:hud_set_flags(player:hud_get_flags()) player:hud_set_flags(player:hud_get_flags())
end end
if player:hud_get_flags().healthbar and if player:hud_get_flags().healthbar and enable_damage then
core.is_yes(core.setting_get("enable_damage")) then
if hud_ids[name].id_healthbar == nil then if hud_ids[name].id_healthbar == nil then
health_bar_definition.number = player:get_hp() health_bar_definition.number = player:get_hp()
hud_ids[name].id_healthbar = player:hud_add(health_bar_definition) hud_ids[name].id_healthbar = player:hud_add(health_bar_definition)
@ -56,8 +57,7 @@ local function initialize_builtin_statbars(player)
end end
if (player:get_breath() < 11) then if (player:get_breath() < 11) then
if player:hud_get_flags().breathbar and if player:hud_get_flags().breathbar and enable_damage then
core.is_yes(core.setting_get("enable_damage")) then
if hud_ids[name].id_breathbar == nil then if hud_ids[name].id_breathbar == nil then
hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition) hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition)
end end