aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/statbars.lua
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2022-07-02 18:28:11 +0100
committerGitHub <noreply@github.com>2022-07-02 18:28:11 +0100
commitb095dc4f2bf2a1ace010dfae0ead69654b0ca3ac (patch)
tree67b2870a0c6f52eab1c7d9dd8cf08660eceb0c13 /builtin/game/statbars.lua
parent45da0d43fdb73bb7c0a746fb8ea6f588a101cace (diff)
downloadminetest-b095dc4f2bf2a1ace010dfae0ead69654b0ca3ac.tar.gz
minetest-b095dc4f2bf2a1ace010dfae0ead69654b0ca3ac.tar.bz2
minetest-b095dc4f2bf2a1ace010dfae0ead69654b0ca3ac.zip
Fix error when `item` isn't provided to core.hud_replace_builtin (#12484)
Diffstat (limited to 'builtin/game/statbars.lua')
-rw-r--r--builtin/game/statbars.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua
index cb7ff7b76..78d1d2728 100644
--- a/builtin/game/statbars.lua
+++ b/builtin/game/statbars.lua
@@ -138,13 +138,15 @@ local function player_event_handler(player,eventname)
end
function core.hud_replace_builtin(hud_name, definition)
-
if type(definition) ~= "table" or
definition.hud_elem_type ~= "statbar" then
return false
end
+ definition = table.copy(definition)
+
if hud_name == "health" then
+ definition.item = definition.item or definition.number or core.PLAYER_MAX_HP_DEFAULT
bar_definitions.hp = definition
for name, ids in pairs(hud_ids) do
@@ -159,6 +161,7 @@ function core.hud_replace_builtin(hud_name, definition)
end
if hud_name == "breath" then
+ definition.item = definition.item or definition.number or core.PLAYER_MAX_BREATH_DEFAULT
bar_definitions.breath = definition
for name, ids in pairs(hud_ids) do