From e9cd7187e88b05a3e972b781cd85ef1e4f2bc10b Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 10 Feb 2017 17:40:57 +0000 Subject: Statbars.lua: Cache enable_damage setting --- builtin/game/statbars.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'builtin/game/statbars.lua') 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 -- cgit v1.2.3 From 43d1f375d18a2fbc547a9b4f23d1354d645856ca Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Fri, 12 Dec 2014 14:49:19 -0500 Subject: Use a settings object for the main settings This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table. --- builtin/game/statbars.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/game/statbars.lua') diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index 4e7781e53..6aa106140 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,5 +1,5 @@ -- cache setting -local enable_damage = core.setting_getbool("enable_damage") == true +local enable_damage = core.settings:get_bool("enable_damage") local health_bar_definition = { -- cgit v1.2.3