Add support for armor texture and preview being functions
parent
ec08032b62
commit
87e41cc9a9
|
@ -205,12 +205,26 @@ function mcl_armor.update(obj)
|
||||||
if not itemstack:is_empty() then
|
if not itemstack:is_empty() then
|
||||||
local def = itemstack:get_definition()
|
local def = itemstack:get_definition()
|
||||||
|
|
||||||
if def._mcl_armor_texture then
|
local texture = def._mcl_armor_texture
|
||||||
info.texture = "(" .. def._mcl_armor_texture .. ")" .. (info.texture and "^" .. info.texture or "")
|
|
||||||
|
if texture then
|
||||||
|
if type(texture) == "function" then
|
||||||
|
texture = texture(obj, itemstack)
|
||||||
|
end
|
||||||
|
if texture then
|
||||||
|
info.texture = "(" .. texture .. ")" .. (info.texture and "^" .. info.texture or "")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if obj:is_player() and def._mcl_armor_preview then
|
local preview = def._mcl_armor_preview
|
||||||
info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" )
|
|
||||||
|
if obj:is_player() and preview then
|
||||||
|
if type(preview) == "function" then
|
||||||
|
preview = preview(obj, itemstack)
|
||||||
|
end
|
||||||
|
if preview then
|
||||||
|
info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
|
info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
|
||||||
|
|
Loading…
Reference in New Issue