Add setting to configure breath bar auto-hiding

This commit is contained in:
Wuzzy 2015-03-23 18:35:19 +01:00
parent 2691a4e320
commit 015e23c6f2
2 changed files with 17 additions and 2 deletions

View File

@ -27,6 +27,15 @@ set will use a default value instead.
IMPORTANT: IMPORTANT:
Keep in mind if running a server with this mod, that the custom position should be displayed correctly on every screen size! Keep in mind if running a server with this mod, that the custom position should be displayed correctly on every screen size!
Settings:
---------
This mod can be configured by editing minetest.conf. Currently, the following setting is recognized:
- hudbars_autohide_breath: A boolean setting, it can be either “true” or “false”. If set to “true”,
the breath bar will be automatically hidden shortly after the breathbar has been filled up. If set
to “false”, the breath bar will always be displayed. The default value is “true”.
API: API:
---- ----
The API is used to add your own custom HUD bars. The API is used to add your own custom HUD bars.

View File

@ -19,6 +19,12 @@ hb.settings.start_offset_right = { x = 15, y = -86 }
hb.settings.vmargin = 24 hb.settings.vmargin = 24
hb.settings.tick = 0.1 hb.settings.tick = 0.1
hb.settings.autohide_breath = true
local autohide_breath = minetest.setting_getbool("hudbars_autohide_breath")
if autohide_breath ~= nil then
hb.settings.autohide_breath = autohide_breath
end
-- Table which contains all players with active default HUD bars (only for internal use) -- Table which contains all players with active default HUD bars (only for internal use)
hb.players = {} hb.players = {}
@ -289,7 +295,7 @@ local function custom_hud(player)
hb.init_hudbar(player, "health", player:get_hp()) hb.init_hudbar(player, "health", player:get_hp())
local breath = player:get_breath() local breath = player:get_breath()
local hide_breath local hide_breath
if breath == 11 then hide_breath = true else hide_breath = false end if breath == 11 and hb.settings.autohide_breath == true then hide_breath = true else hide_breath = false end
hb.init_hudbar(player, "breath", math.min(breath, 10), nil, hide_breath) hb.init_hudbar(player, "breath", math.min(breath, 10), nil, hide_breath)
end end
end end
@ -301,7 +307,7 @@ local function update_hud(player)
--air --air
local breath = player:get_breath() local breath = player:get_breath()
if breath == 11 then if breath == 11 and hb.settings.autohide_breath == true then
hb.hide_hudbar(player, "breath") hb.hide_hudbar(player, "breath")
else else
hb.unhide_hudbar(player, "breath") hb.unhide_hudbar(player, "breath")