diff --git a/mods/hudbars/default_settings.lua b/mods/hudbars/default_settings.lua index d2f11c8..04475ac 100644 --- a/mods/hudbars/default_settings.lua +++ b/mods/hudbars/default_settings.lua @@ -50,3 +50,8 @@ end hb.settings.hp_player_maximun = hb.load_setting("hudbars_hp_player_maximun", "number", 20) hb.settings.br_player_maximun = hb.load_setting("hudbars_br_player_maximun", "number", 10) +if minetest.has_feature("object_use_texture_alpha") then +core.PLAYER_MAX_HP_DEFAULT = hb.settings.hp_player_maximun +else +core.PLAYER_MAX_HP = hb.settings.hp_player_maximun +end diff --git a/mods/hudbars/init.lua b/mods/hudbars/init.lua index 378c37e..3133ff4 100644 --- a/mods/hudbars/init.lua +++ b/mods/hudbars/init.lua @@ -74,6 +74,19 @@ local function player_exists(player) return player ~= nil and player:is_player() end +local function checksupportmax(player) + local statusinfo = minetest.get_server_status() + if string.find(statusinfo,"0.4.1") and not string.find(statusinfo,"0.4.18") and not string.find(statusinfo,"0.4.17.5") then + hb.settings.hp_player_maximun = 20 + hb.settings.br_player_maximun = 10 + if player_exists(player) then + player:set_properties({hp_max = 20}) + else + minetest.log("error","[hudbars] WARNING! minetest version do not support customization of hp_max healt player values") + end + end +end + local function make_label(format_string, format_string_config, label, start_value, max_value) local params = {} local order = format_string_config.order @@ -143,6 +156,7 @@ function hb.get_hudbar_position_index(identifier) end function hb.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, default_start_hidden, format_string, format_string_config) + checksupportmax() minetest.log("action", "hb.register_hudbar: "..tostring(identifier)) local hudtable = {} local pos, offset @@ -331,6 +345,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta end function hb.init_hudbar(player, identifier, start_value, start_max, start_hidden) + checksupportmax(player) if not player_exists(player) then return false end local hudtable = hb.get_hudtable(identifier) hb.hudtables[identifier].add_all(player, hudtable, start_value, start_max, start_hidden)