summaryrefslogtreecommitdiff
path: root/legacy.lua
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2016-02-15 14:19:00 +0100
committerBlockMen <nmuelll@web.de>2016-02-15 14:19:00 +0100
commitc58f7034e6472575dffdc1decda00d8f40383501 (patch)
treec2a0319d270446717297eb0213636eb7720e7a80 /legacy.lua
parentfb0a4f2f10b81d9f3d730bb66f75fe0d9a7e56c5 (diff)
Fixed armor not being updated correct due armor mod changesHEADorigin/masterorigin/HEADmaster
- Fixes #2
Diffstat (limited to 'legacy.lua')
-rw-r--r--legacy.lua89
1 files changed, 45 insertions, 44 deletions
diff --git a/legacy.lua b/legacy.lua
index 596ada3..1badc06 100644
--- a/legacy.lua
+++ b/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 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 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
- 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