forked from mtcontrib/minetest_hbarmor
Disable armor hiding
This commit is contained in:
parent
112f791291
commit
903f34ff32
17
init.lua
17
init.lua
@ -11,6 +11,10 @@ local armor_hud = {}
|
|||||||
|
|
||||||
hbarmor.tick = 0.1
|
hbarmor.tick = 0.1
|
||||||
|
|
||||||
|
-- If true, the armor bar is hidden when the player does not wear any armor
|
||||||
|
-- FIXME: Currently hiding does not work, so it is turned off by default.
|
||||||
|
hbarmor.autohide = false
|
||||||
|
|
||||||
--load custom settings
|
--load custom settings
|
||||||
local set = io.open(minetest.get_modpath("hbarmor").."/hbarmor.conf", "r")
|
local set = io.open(minetest.get_modpath("hbarmor").."/hbarmor.conf", "r")
|
||||||
if set then
|
if set then
|
||||||
@ -32,13 +36,18 @@ local function custom_hud(player)
|
|||||||
if minetest.setting_getbool("enable_damage") then
|
if minetest.setting_getbool("enable_damage") then
|
||||||
local arm = tonumber(hbarmor.armor[name])
|
local arm = tonumber(hbarmor.armor[name])
|
||||||
if not arm then arm = 0 end
|
if not arm then arm = 0 end
|
||||||
local hide = must_hide(name, arm)
|
local hide
|
||||||
|
if hbarmor.autohide then
|
||||||
|
hide = must_hide(name, arm)
|
||||||
|
else
|
||||||
|
hide = false
|
||||||
|
end
|
||||||
hb.init_hudbar(player, "armor", arm_printable(arm), nil, hide)
|
hb.init_hudbar(player, "armor", arm_printable(arm), nil, hide)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--register and define armor HUD bar
|
--register and define armor HUD bar
|
||||||
hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bar = "hbarmor_bar.png" }, 0, 100, true, "%s: %d%%")
|
hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, "%s: %d%%")
|
||||||
|
|
||||||
dofile(minetest.get_modpath("hbarmor").."/armor.lua")
|
dofile(minetest.get_modpath("hbarmor").."/armor.lua")
|
||||||
|
|
||||||
@ -52,6 +61,7 @@ local function update_hud(player)
|
|||||||
arm = 0
|
arm = 0
|
||||||
hbarmor.armor[name] = 0
|
hbarmor.armor[name] = 0
|
||||||
end
|
end
|
||||||
|
if hb.autohide then
|
||||||
-- hide armor bar completely when there is none
|
-- hide armor bar completely when there is none
|
||||||
if must_hide(name, arm) then
|
if must_hide(name, arm) then
|
||||||
hb.hide_hudbar(player, "armor")
|
hb.hide_hudbar(player, "armor")
|
||||||
@ -59,6 +69,9 @@ local function update_hud(player)
|
|||||||
hb.change_hudbar(player, "armor", arm_printable(arm))
|
hb.change_hudbar(player, "armor", arm_printable(arm))
|
||||||
hb.unhide_hudbar(player, "armor")
|
hb.unhide_hudbar(player, "armor")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
hb.change_hudbar(player, "armor", arm_printable(arm))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
Loading…
Reference in New Issue
Block a user