2013-04-11 21:56:35 +02:00
|
|
|
|
|
|
|
uniskins = {
|
2013-06-22 20:31:57 +02:00
|
|
|
skin = {},
|
|
|
|
armor = {},
|
|
|
|
wielditem = {},
|
|
|
|
default_skin = "character.png",
|
2013-06-24 20:06:19 +02:00
|
|
|
default_texture = nil,
|
2013-04-11 21:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uniskins.update_player_visuals = function(self, player)
|
|
|
|
if not player then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local name = player:get_player_name()
|
2013-06-22 20:31:57 +02:00
|
|
|
local texture = "uniskins_trans.png"
|
|
|
|
if self.wielditem[name] then
|
2013-06-24 20:06:19 +02:00
|
|
|
texture = texture.."^[combine:64x80:48,64="..self.wielditem[name]
|
2013-04-11 21:56:35 +02:00
|
|
|
end
|
2013-06-22 20:31:57 +02:00
|
|
|
if self.skin[name] then
|
2013-06-24 20:06:19 +02:00
|
|
|
texture = texture.."^[combine:64x80:0,32="..self.skin[name]
|
2013-06-22 20:31:57 +02:00
|
|
|
end
|
|
|
|
if self.armor[name] then
|
2013-06-24 20:06:19 +02:00
|
|
|
texture = texture.."^[combine:64x80:0,0="..self.armor[name]
|
2013-04-11 21:56:35 +02:00
|
|
|
end
|
|
|
|
player:set_properties({
|
|
|
|
visual = "mesh",
|
2013-06-22 20:31:57 +02:00
|
|
|
mesh = "uniskins_character.x",
|
2013-04-11 21:56:35 +02:00
|
|
|
textures = {texture},
|
|
|
|
visual_size = {x=1, y=1},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
local name = player:get_player_name()
|
2013-06-22 20:31:57 +02:00
|
|
|
uniskins.skin[name] = uniskins.default_skin
|
|
|
|
if minetest.get_modpath("player_textures") then
|
|
|
|
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
|
|
|
local f = io.open(filename..".png")
|
|
|
|
if f then
|
|
|
|
f:close()
|
|
|
|
uniskins.skin[name] = "player_"..name..".png"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if minetest.get_modpath("skins") then
|
|
|
|
local skin = skins.skins[name]
|
|
|
|
if skin and skins.get_type(skin) == skins.type.MODEL then
|
|
|
|
uniskins.skin[name] = skin..".png"
|
|
|
|
end
|
2013-04-11 21:56:35 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|