diff --git a/README.txt b/README.txt index 3f05e2f..916b7f6 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ Modpack "Better HUD and hunger" =============================== -ModPack-Version: 2.x.0 +ModPack-Version: 2.x.1 -Copyright (c) 2013-2015 BlockMen +Copyright (c) 2013-2016 BlockMen About this mod: @@ -36,7 +36,7 @@ For more information how to register more food see API.txt License: ~~~~~~~~ -(c) Copyright BlockMen (2013-2015) +(c) Copyright BlockMen (2013-2016) Code: diff --git a/hud/README.txt b/hud/README.txt index 80fc331..93ecfa7 100644 --- a/hud/README.txt +++ b/hud/README.txt @@ -1,8 +1,8 @@ Minetest mod "Better HUD" ========================= -Version: 2.1.4 +Version: 2.1.5 -(c) Copyright BlockMen (2013-2015) +(c) Copyright BlockMen (2013-2016) About this mod: @@ -26,7 +26,7 @@ This mod supports the 3d_armor mod by stu (https://github.com/stujones11/minetes License: ~~~~~~~~ -(c) Copyright BlockMen (2013-2015) +(c) Copyright BlockMen (2013-2016) Code: diff --git a/hud/changelog.txt b/hud/changelog.txt index 54a6a87..d34cb17 100644 --- a/hud/changelog.txt +++ b/hud/changelog.txt @@ -1,3 +1,7 @@ +2.1.5 +----- +- Fixed armor not being updated correct due armor mod changes + 2.1.4 ----- - Fixed unhandled exception in hud.swap_statbar() diff --git a/hud/legacy.lua b/hud/legacy.lua index 596ada3..1badc06 100644 --- a/hud/legacy.lua +++ b/hud/legacy.lua @@ -3,59 +3,60 @@ function hud.set_armor() end if hud.show_armor then - local shields = minetest.get_modpath("shields") ~= nil - local armor_org_func = armor.update_armor + local shields = minetest.get_modpath("shields") ~= nil + local armor_org_func = armor.set_player_armor - local function get_armor_lvl(def) - -- items/protection based display - local lvl = def.level or 0 - local max = 63 -- full diamond armor - if shields then - max = 84.14 -- full diamond armor + diamond shield - end - -- TODO: is there a sane way to read out max values? - local ret = lvl/max - if ret > 1 then - ret = 1 - end - - return tonumber(20 * ret) + local function get_armor_lvl(def) + -- items/protection based display + local lvl = def.level or 0 + local max = 63 -- full diamond armor + if shields then + max = 84.14 -- full diamond armor + diamond shield + end + -- TODO: is there a sane way to read out max values? + local ret = lvl/max + if ret > 1 then + ret = 1 end - function armor.update_armor(self, player) - armor_org_func(self, player) - local name = player:get_player_name() - local def = self.def - local armor_lvl = 0 - if def[name] and def[name].level then - armor_lvl = get_armor_lvl(def[name]) - end - hud.change_item(player, "armor", {number = armor_lvl}) + return tonumber(20 * ret) + end + + function armor.set_player_armor(self, player) + armor_org_func(self, player) + local name = player:get_player_name() + local def = self.def + local armor_lvl = 0 + if def[name] and def[name].level then + armor_lvl = get_armor_lvl(def[name]) end + hud.change_item(player, "armor", {number = armor_lvl}) + end end -- Hunger related functions if not hud.show_hunger then - function hud.set_hunger() - hud.notify_hunger(1, true) - end + function hud.set_hunger() + hud.notify_hunger(1, true) + end - function hud.get_hunger() - hud.notify_hunger(1, true) - end + function hud.get_hunger() + hud.notify_hunger(1, true) + end - function hud.item_eat(hp_change, replace_with_item) - return function(itemstack, user, pointed_thing) - hud.notify_hunger(1, true) - local func = minetest.item_eat(hp_change, replace_with_item) - return func(itemstack, user, pointed_thing) - end + function hud.item_eat(hp_change, replace_with_item) + return function(itemstack, user, pointed_thing) + hud.notify_hunger(1, true) + local func = minetest.item_eat(hp_change, replace_with_item) + return func(itemstack, user, pointed_thing) end + end - function hud.save_hunger() - hud.notify_hunger(1, true) - end - function hud.load_hunger(player) - hud.notify_hunger(1, true) - end + function hud.save_hunger() + hud.notify_hunger(1, true) + end + + function hud.load_hunger(player) + hud.notify_hunger(1, true) + end end