diff --git a/mods/HUD/hbarmor/depends.txt b/mods/HUD/hbarmor/depends.txt deleted file mode 100644 index 32c22245ff..0000000000 --- a/mods/HUD/hbarmor/depends.txt +++ /dev/null @@ -1,3 +0,0 @@ -hudbars -3d_armor -intllib? diff --git a/mods/HUD/hbarmor/init.lua b/mods/HUD/hbarmor/init.lua index 21193f9128..c2530b61ff 100644 --- a/mods/HUD/hbarmor/init.lua +++ b/mods/HUD/hbarmor/init.lua @@ -1,9 +1,4 @@ -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("hbarmor") if (not armor) or (not armor.def) then minetest.log("error", "[hbarmor] Outdated 3d_armor version. Please update your version of 3d_armor!") @@ -51,9 +46,12 @@ local function custom_hud(player) local ret = hbarmor.get_armor(player) if ret == false then minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in custom_hud returned with false!") + return end local arm = tonumber(hbarmor.armor[name]) - if not arm then arm = 0 end + if not arm then + arm = 0 + end local hide if hbarmor.autohide then hide = must_hide(name, arm) @@ -65,35 +63,24 @@ local function custom_hud(player) end --register and define armor HUD bar -hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, S("%s: %d%%")) +hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 20, hbarmor.autohide) function hbarmor.get_armor(player) if not player or not armor.def then return false end local name = player:get_player_name() - local def = armor.def[name] or nil - if def and def.state and def.count then - hbarmor.set_armor(name, def.state, def.count) - else + local pts = armor:get_armor_points(player) + if not pts then return false + else + hbarmor.set_armor(name, pts) end return true end -function hbarmor.set_armor(player_name, ges_state, items) - local max_items = 4 - if items == 5 then - max_items = items - end - local max = max_items * 65535 - local lvl = max - ges_state - lvl = lvl/max - if ges_state == 0 and items == 0 then - lvl = 0 - end - - hbarmor.armor[player_name] = math.max(0, math.min(lvl* (items * (100 / max_items)), 100)) +function hbarmor.set_armor(player_name, pts) + hbarmor.armor[player_name] = math.max(0, math.min(20, pts)) end -- update hud elemtens if value has changed diff --git a/mods/HUD/hbarmor/locale/hbarmor.de.tr b/mods/HUD/hbarmor/locale/hbarmor.de.tr index d1be86985b..e7aa7d785c 100644 --- a/mods/HUD/hbarmor/locale/hbarmor.de.tr +++ b/mods/HUD/hbarmor/locale/hbarmor.de.tr @@ -1,2 +1,2 @@ +# textdomain:hbarmor Armor=Panzerung -%s: %d%%=%s: %d%% diff --git a/mods/HUD/hbarmor/locale/hbarmor.es.tr b/mods/HUD/hbarmor/locale/hbarmor.es.tr index 78bd409fd2..f9529b482a 100644 --- a/mods/HUD/hbarmor/locale/hbarmor.es.tr +++ b/mods/HUD/hbarmor/locale/hbarmor.es.tr @@ -1,2 +1,2 @@ +# textdomain:hbarmor Armor=Armadura -%s: %d%%=%s: %d%% diff --git a/mods/HUD/hbarmor/locale/hbarmor.it.tr b/mods/HUD/hbarmor/locale/hbarmor.it.tr index f9c8f99e37..f02b5c435a 100644 --- a/mods/HUD/hbarmor/locale/hbarmor.it.tr +++ b/mods/HUD/hbarmor/locale/hbarmor.it.tr @@ -1,4 +1,2 @@ +# textdomain:hbarmor Armor=Armatura - -# Format string for displaying the armor. E.g. "Armor: 100%" -%s: %d%%=%s: %d%% diff --git a/mods/HUD/hbarmor/locale/template.txt b/mods/HUD/hbarmor/locale/template.txt index 09bc54cefc..80e7a09e8b 100644 --- a/mods/HUD/hbarmor/locale/template.txt +++ b/mods/HUD/hbarmor/locale/template.txt @@ -1,4 +1,2 @@ +# textdomain:hbarmor Armor= - -# Format string for displaying the armor. E.g. "Armor: 100%" -%s: %d%%= diff --git a/mods/HUD/hbarmor/mod.conf b/mods/HUD/hbarmor/mod.conf index 47352c19db..80d3891044 100644 --- a/mods/HUD/hbarmor/mod.conf +++ b/mods/HUD/hbarmor/mod.conf @@ -1 +1,2 @@ name = hbarmor +depends = hudbars, 3d_armor diff --git a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua index 4d1eb0a427..adfb029192 100644 --- a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua @@ -205,7 +205,7 @@ armor.get_armor_points = function(self, player) for i=1, 6 do local stack = player_inv:get_stack("armor", i) if stack:get_count() > 0 then - local p = stack:get_definition().groups.mcl_armor_points + local p = minetest.get_item_group(stack:get_name(), "mcl_armor_points") if p then pts = pts + p end