summaryrefslogtreecommitdiff
path: root/player_textures/init.lua
blob: 5aa2ec49335d73ba609fb3c104862c3a2a269276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local function pivot(table)
	local ret = {}
	for k,v in pairs(table) do
		ret[v] = k
	end
	return ret
end

local textures = pivot(minetest.get_dir_list(minetest.get_modpath("player_textures")..DIR_DELIM.."textures"))

local function applyskin(player)
	local name = player:get_player_name()
	if textures[string.format("player_%s.png",name)] then
		if minetest.get_modpath("default") then
			default.player_set_textures(player,string.format("[combine:64x32:0,0=player_%s.png",name))
		end
		player:set_properties({textures={string.format("[combine:64x32:0,0=player_%s.png",name)}})
	end
	player:set_properties({visual="mesh",visual_size={x=1,y=1},mesh="character.b3d"})
end

minetest.register_on_joinplayer(function(player)
	applyskin(player)
	minetest.after(10,applyskin,player)
end)