From 7ece8b87bec0451f24c2d8e2cffcd06b12a0262b Mon Sep 17 00:00:00 2001 From: BlockMen Date: Wed, 8 Apr 2015 20:24:01 +0200 Subject: Fix hud_flags (fixes #20); check player once more --- api.lua | 9 ++++++--- builtin.lua | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api.lua b/api.lua index cdd9632..c40d857 100644 --- a/api.lua +++ b/api.lua @@ -11,7 +11,7 @@ local sb_bg = {} -- statbar background ids local items = hud.registered_items local function throw_error(msg) - minetest.chat_send_all(msg) + minetest.log("error", "Better HUD[error]: " .. msg) end @@ -67,7 +67,7 @@ function hud.register(name, def) end function hud.change_item(player, name, def) - if not player or not name or not def then + if not player or not player:is_player() or not name or not def then throw_error("Not enough parameters given to change HUD item") return false end @@ -185,7 +185,10 @@ end minetest.register_on_joinplayer(function(player) -- first: hide the default statbars - player:hud_set_flags({healthbar = false, breathbar = false}) + local hud_flags = player:hud_get_flags() + hud_flags.healthbar = false + hud_flags.breathbar = false + player:hud_set_flags(hud_flags) -- now add the backgrounds (e.g. for statbars) for _,item in pairs(sb_bg) do diff --git a/builtin.lua b/builtin.lua index b82ba41..7169c4c 100644 --- a/builtin.lua +++ b/builtin.lua @@ -80,7 +80,7 @@ if damage_enabled then }) local start_value = 0 - if show_hunger then + if hud.show_hunger then start_value = 20 end -- cgit v1.2.3