forked from mtcontrib/3d_armor
Add support for Better HUD mod
This commit is contained in:
parent
02ba28f11b
commit
9481e548cf
|
@ -24,6 +24,8 @@ armor.set_player_armor = function(self, player)
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
local armor_texture = uniskins.default_texture
|
local armor_texture = uniskins.default_texture
|
||||||
local armor_level = 0
|
local armor_level = 0
|
||||||
|
local state = 0
|
||||||
|
local items = 0
|
||||||
local textures = {}
|
local textures = {}
|
||||||
for _,v in ipairs(self.elements) do
|
for _,v in ipairs(self.elements) do
|
||||||
local stack = player_inv:get_stack("armor_"..v, 1)
|
local stack = player_inv:get_stack("armor_"..v, 1)
|
||||||
|
@ -32,6 +34,8 @@ armor.set_player_armor = function(self, player)
|
||||||
local item = stack:get_name()
|
local item = stack:get_name()
|
||||||
table.insert(textures, item:gsub("%:", "_")..".png")
|
table.insert(textures, item:gsub("%:", "_")..".png")
|
||||||
armor_level = armor_level + level
|
armor_level = armor_level + level
|
||||||
|
state = state + stack:get_wear()
|
||||||
|
items = items+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if table.getn(textures) > 0 then
|
if table.getn(textures) > 0 then
|
||||||
|
@ -45,6 +49,9 @@ armor.set_player_armor = function(self, player)
|
||||||
player:set_armor_groups(armor_groups)
|
player:set_armor_groups(armor_groups)
|
||||||
uniskins.armor[name] = armor_texture
|
uniskins.armor[name] = armor_texture
|
||||||
uniskins:update_player_visuals(player)
|
uniskins:update_player_visuals(player)
|
||||||
|
if minetest.get_modpath("hud") ~= nil then
|
||||||
|
hud.set_armor(player, state, items)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
armor.update_armor = function(self, player)
|
armor.update_armor = function(self, player)
|
||||||
|
@ -63,6 +70,8 @@ armor.update_armor = function(self, player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local heal_max = 0
|
local heal_max = 0
|
||||||
|
local state = 0
|
||||||
|
local items = 0
|
||||||
for _,v in ipairs(self.elements) do
|
for _,v in ipairs(self.elements) do
|
||||||
local stack = armor_inv:get_stack("armor_"..v, 1)
|
local stack = armor_inv:get_stack("armor_"..v, 1)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
|
@ -72,6 +81,8 @@ armor.update_armor = function(self, player)
|
||||||
stack:add_wear(use)
|
stack:add_wear(use)
|
||||||
armor_inv:set_stack("armor_"..v, 1, stack)
|
armor_inv:set_stack("armor_"..v, 1, stack)
|
||||||
player_inv:set_stack("armor_"..v, 1, stack)
|
player_inv:set_stack("armor_"..v, 1, stack)
|
||||||
|
state = state + stack:get_wear()
|
||||||
|
items = items+1
|
||||||
if stack:get_count() == 0 then
|
if stack:get_count() == 0 then
|
||||||
local desc = minetest.registered_items[item].description
|
local desc = minetest.registered_items[item].description
|
||||||
if desc then
|
if desc then
|
||||||
|
@ -82,6 +93,9 @@ armor.update_armor = function(self, player)
|
||||||
heal_max = heal_max + heal
|
heal_max = heal_max + heal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if minetest.get_modpath("hud") ~= nil then
|
||||||
|
hud.set_armor(player, state, items)
|
||||||
|
end
|
||||||
if heal_max > math.random(100) then
|
if heal_max > math.random(100) then
|
||||||
player:set_hp(self.player_hp[name])
|
player:set_hp(self.player_hp[name])
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user