aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authortenplus1 <tenplus1@users.noreply.github.com>2017-02-10 17:40:57 +0000
committerparamat <mat.gregory@virginmedia.com>2017-02-18 22:46:06 +0000
commite9cd7187e88b05a3e972b781cd85ef1e4f2bc10b (patch)
tree460666ed97760ff8518b99554d043f52460b9239 /builtin/game
parent5db41d4d213333fc39845e7b752d7976a24da6af (diff)
downloadminetest-e9cd7187e88b05a3e972b781cd85ef1e4f2bc10b.tar.gz
minetest-e9cd7187e88b05a3e972b781cd85ef1e4f2bc10b.tar.bz2
minetest-e9cd7187e88b05a3e972b781cd85ef1e4f2bc10b.zip
Statbars.lua: Cache enable_damage setting
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/statbars.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua
index 61a8b9077..4e7781e53 100644
--- a/builtin/game/statbars.lua
+++ b/builtin/game/statbars.lua
@@ -1,3 +1,5 @@
+-- cache setting
+local enable_damage = core.setting_getbool("enable_damage") == true
local health_bar_definition =
{
@@ -42,9 +44,8 @@ local function initialize_builtin_statbars(player)
player:hud_set_flags(player:hud_get_flags())
end
- if player:hud_get_flags().healthbar and
- core.is_yes(core.setting_get("enable_damage")) then
- if hud_ids[name].id_healthbar == nil then
+ if player:hud_get_flags().healthbar and enable_damage then
+ if hud_ids[name].id_healthbar == nil then
health_bar_definition.number = player:get_hp()
hud_ids[name].id_healthbar = player:hud_add(health_bar_definition)
end
@@ -56,8 +57,7 @@ local function initialize_builtin_statbars(player)
end
if (player:get_breath() < 11) then
- if player:hud_get_flags().breathbar and
- core.is_yes(core.setting_get("enable_damage")) then
+ if player:hud_get_flags().breathbar and enable_damage then
if hud_ids[name].id_breathbar == nil then
hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition)
end