summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2015-04-08 20:24:01 +0200
committerBlockMen <nmuelll@web.de>2015-04-08 20:24:01 +0200
commit7ece8b87bec0451f24c2d8e2cffcd06b12a0262b (patch)
tree0f596ad08ab23e9aafbb576f9bfa658f03f47d7c /api.lua
parent1071c7f13e491b2f3bc09bbbcb1bd6aaed6071c5 (diff)
Fix hud_flags (fixes #20); check player once more
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua9
1 files changed, 6 insertions, 3 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