return the png suffix in get_player_skin for complete texture definition to support more complex textures

Note the armor.get_player_skin() could be redefined in other mods to privide the more complex textures
This commit is contained in:
Alexander Weber 2017-06-18 22:13:48 +02:00 committed by stujones11
parent 9577fb773e
commit 2150fcea8d
2 changed files with 9 additions and 10 deletions

View File

@ -376,18 +376,17 @@ armor.damage = function(self, player, index, stack, use)
end end
armor.get_player_skin = function(self, name) armor.get_player_skin = function(self, name)
local skin = nil if self.skin_mod == "skins" or self.skin_mod == "simple_skins" and skins.skins[name] then
if self.skin_mod == "skins" or self.skin_mod == "simple_skins" then return skins.skins[name]..".png"
skin = skins.skins[name] elseif self.skin_mod == "u_skins" and u_skins.u_skins[name] then
elseif self.skin_mod == "u_skins" then return u_skins.u_skins[name]..".png"
skin = u_skins.u_skins[name]
elseif self.skin_mod == "wardrobe" then elseif self.skin_mod == "wardrobe" then
local skins = wardrobe.playerSkins or {} local skins = wardrobe.playerSkins or {}
if skins[name] then if skins[name] then
skin = string.gsub(skins[name], "%.png$","") return skins[name]
end end
end end
return skin or armor.default_skin return armor.default_skin..".png"
end end
armor.add_preview = function(self, preview) armor.add_preview = function(self, preview)
@ -395,7 +394,7 @@ armor.add_preview = function(self, preview)
end end
armor.get_preview = function(self, name) armor.get_preview = function(self, name)
local preview = armor:get_player_skin(name).."_preview.png" local preview = string.gsub(armor:get_player_skin(name), ".png", "_preview.png")
if skin_previews[preview] then if skin_previews[preview] then
return preview return preview
end end

View File

@ -177,7 +177,7 @@ local function init_player_armor(player)
end end
local skin = armor:get_player_skin(name) local skin = armor:get_player_skin(name)
armor.textures[name] = { armor.textures[name] = {
skin = skin..".png", skin = skin,
armor = "3d_armor_trans.png", armor = "3d_armor_trans.png",
wielditem = "3d_armor_trans.png", wielditem = "3d_armor_trans.png",
preview = armor.default_skin.."_preview.png", preview = armor.default_skin.."_preview.png",
@ -224,7 +224,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if string.find(field, "skins_set") then if string.find(field, "skins_set") then
minetest.after(0, function(player) minetest.after(0, function(player)
local skin = armor:get_player_skin(name) local skin = armor:get_player_skin(name)
armor.textures[name].skin = skin..".png" armor.textures[name].skin = skin
armor:set_player_armor(player) armor:set_player_armor(player)
end, player) end, player)
end end