Improve skin mod preview support

This commit is contained in:
stujones11 2017-03-12 18:23:49 +00:00
parent 80024fc154
commit b59464de88

@ -34,6 +34,7 @@ local skin_mod = nil
local inv_mod = nil local inv_mod = nil
local use_player_monoids = minetest.global_exists("player_monoids") local use_player_monoids = minetest.global_exists("player_monoids")
local use_armor_monoid = minetest.global_exists("armor_monoid") local use_armor_monoid = minetest.global_exists("armor_monoid")
local preview_textures = {}
local modpath = minetest.get_modpath(ARMOR_MOD_NAME) local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local worldpath = minetest.get_worldpath() local worldpath = minetest.get_worldpath()
@ -136,17 +137,20 @@ elseif minetest.get_modpath("sfinv") then
}) })
end end
if minetest.get_modpath("skins") then local skin_mods = {"skins", "u_skins", "simple_skins", "wardrobe"}
skin_mod = "skins" for _, mod in pairs(skin_mods) do
elseif minetest.get_modpath("simple_skins") then local path = minetest.get_modpath(mod)
skin_mod = "simple_skins" if path then
elseif minetest.get_modpath("u_skins") then local dir_list = minetest.get_dir_list(path.."/textures")
skin_mod = "u_skins" for _, fn in pairs(dir_list) do
elseif minetest.get_modpath("wardrobe") then if fn:find("_preview.png$") then
skin_mod = "wardrobe" preview_textures[fn] = true
end
end
skin_mod = mod
end
end end
armor.def = { armor.def = {
state = 0, state = 0,
count = 0, count = 0,
@ -183,7 +187,7 @@ armor.set_player_armor = function(self, player)
local textures = {} local textures = {}
local physics_o = {speed=1,gravity=1,jump=1} local physics_o = {speed=1,gravity=1,jump=1}
local material = {type=nil, count=1} local material = {type=nil, count=1}
local preview = armor:get_preview(name) or "character_preview.png" local preview = armor:get_preview(name)
for _,v in ipairs(self.elements) do for _,v in ipairs(self.elements) do
elements[v] = false elements[v] = false
end end
@ -294,9 +298,11 @@ armor.get_player_skin = function(self, name)
end end
armor.get_preview = function(self, name) armor.get_preview = function(self, name)
if skin_mod == "u_skins" then local preview = armor:get_player_skin(name).."_preview.png"
return armor:get_player_skin(name).."_preview.png" if preview_textures[preview] then
return preview
end end
return "character_preview.png"
end end
armor.get_armor_formspec = function(self, name, listring) armor.get_armor_formspec = function(self, name, listring)