btmt_hudarmor = {}

local damages =  minetest.settings:get_bool("enable_damage")

if damages then

function btmt_hud_armor(player)
 local player_name = player:get_player_name()
 local level_armor = armor.def[player_name].level or 0
 local armor_total = level_armor / 5
 
 --if armor_total > 20 then
  -- armor_total =  armor_total - (armor_total - 20)
-- end

 if not btmt_hudarmor[player_name] then
    btmt_hudarmor[player_name]  = player:hud_add({
        name = "armor_stats",
        hud_elem_type = "statbar",
        position = {x = 0.5, y = 1},
        size = {x = 24, y = 24},
        text2 = "btm_armor_bg.png",
        text = "btm_armor_icon.png",      
        number = 0,
        alignment = {x = -1, y = -1},
        offset = {x = 25, y = -110},
        max = 0,
    })
 end

 player:hud_change(btmt_hudarmor[player_name], "number", armor_total)
-- core.log(tostring(armor_total))
end

armor:register_on_update(function(player)
  btmt_hud_armor(player)
end)

end

