3d_armor/unified_skins/init.lua

52 lines
1.3 KiB
Lua
Raw Normal View History

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,
}
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]
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]
end
player:set_properties({
visual = "mesh",
2013-06-22 20:31:57 +02:00
mesh = "uniskins_character.x",
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
end
end)