Merge pull request #5 from BlockMen/2nd

Better implementation of support for hud
This commit is contained in:
stujones11 2013-09-13 10:38:44 -07:00
commit f71204db09

View File

@ -16,6 +16,11 @@ armor = {
.."list[detached:player_name_armor;armor_feet;3,3;1,1;]", .."list[detached:player_name_armor;armor_feet;3,3;1,1;]",
} }
armor.def = {
state = 0,
count = 0
}
armor.set_player_armor = function(self, player) armor.set_player_armor = function(self, player)
if not player then if not player then
return return
@ -49,9 +54,8 @@ 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 armor.def[name].state = state
hud.set_armor(player, state, items) armor.def[name].count = items
end
end end
armor.update_armor = function(self, player) armor.update_armor = function(self, player)
@ -93,9 +97,8 @@ 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 armor.def[name].state = state
hud.set_armor(player, state, items) armor.def[name].count = 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
@ -155,7 +158,11 @@ minetest.register_on_joinplayer(function(player)
armor_inv:set_size(list, 1) armor_inv:set_size(list, 1)
armor_inv:set_stack(list, 1, player_inv:get_stack(list, 1)) armor_inv:set_stack(list, 1, player_inv:get_stack(list, 1))
end end
armor.player_hp[name] = 0 armor.player_hp[name] = 0
armor.def[name] = {
state = 0,
count = 0
}
minetest.after(0, function(player) minetest.after(0, function(player)
armor:set_player_armor(player) armor:set_player_armor(player)
end, player) end, player)