forked from mtcontrib/3d_armor
Fix preview not updating when armor is destroyed
This commit is contained in:
parent
72b612f081
commit
19d45efd12
|
@ -192,6 +192,7 @@ armor.update_armor = function(self, player)
|
||||||
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
||||||
end
|
end
|
||||||
self:set_player_armor(player)
|
self:set_player_armor(player)
|
||||||
|
armor:update_inventory(player)
|
||||||
end
|
end
|
||||||
heal_max = heal_max + heal
|
heal_max = heal_max + heal
|
||||||
end
|
end
|
||||||
|
@ -217,20 +218,29 @@ armor.get_player_skin = function(self, name)
|
||||||
return skin or armor.default_skin
|
return skin or armor.default_skin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
armor.get_armor_formspec = function(self, name)
|
||||||
|
local formspec = armor.formspec:gsub("player_name", name)
|
||||||
|
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
||||||
|
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
||||||
|
return formspec:gsub("armor_heal", armor.def[name].heal)
|
||||||
|
end
|
||||||
|
|
||||||
armor.update_inventory = function(self, player)
|
armor.update_inventory = function(self, player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if unified_inventory then
|
if unified_inventory then
|
||||||
unified_inventory.set_inventory_formspec(player, "armor")
|
if unified_inventory.current_page[name] == "armor" then
|
||||||
elseif inventory_plus then
|
unified_inventory.set_inventory_formspec(player, "armor")
|
||||||
local formspec = armor.formspec:gsub("player_name", name)
|
end
|
||||||
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
|
||||||
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
|
||||||
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
|
|
||||||
inventory_plus.set_inventory_formspec(player, formspec)
|
|
||||||
else
|
else
|
||||||
local formspec = armor.formspec:gsub("player_name", name)
|
local formspec = armor:get_armor_formspec(name)
|
||||||
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
if inventory_plus then
|
||||||
player:set_inventory_formspec(formspec)
|
local page = player:get_inventory_formspec()
|
||||||
|
if page:find("detached:"..name.."_armor") then
|
||||||
|
inventory_plus.set_inventory_formspec(player, formspec)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
player:set_inventory_formspec(formspec)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -257,8 +267,9 @@ default.player_register_model("3d_armor_character.x", {
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if fields.armor then
|
if inventory_plus and fields.armor then
|
||||||
armor:update_inventory(player)
|
local formspec = armor:get_armor_formspec(name)
|
||||||
|
inventory_plus.set_inventory_formspec(player, formspec)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for field, _ in pairs(fields) do
|
for field, _ in pairs(fields) do
|
||||||
|
@ -382,14 +393,7 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
armor:set_player_armor(player)
|
armor:set_player_armor(player)
|
||||||
if unified_inventory then
|
armor:update_inventory(player)
|
||||||
unified_inventory.set_inventory_formspec(player, "craft")
|
|
||||||
elseif inventory_plus then
|
|
||||||
local formspec = inventory_plus.get_formspec(player,"main")
|
|
||||||
inventory_plus.set_inventory_formspec(player, formspec)
|
|
||||||
else
|
|
||||||
armor:update_inventory(player)
|
|
||||||
end
|
|
||||||
if ARMOR_DESTROY == false then
|
if ARMOR_DESTROY == false then
|
||||||
if minetest.get_modpath("bones") then
|
if minetest.get_modpath("bones") then
|
||||||
minetest.after(ARMOR_BONES_DELAY, function()
|
minetest.after(ARMOR_BONES_DELAY, function()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user