forked from VoxeLibre/VoxeLibre
mcl_skins: Add fallback code if skin was missing
This commit is contained in:
parent
5601f8e0b7
commit
62eaf60938
|
@ -73,6 +73,7 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
||||||
if minetest.get_modpath("mcl_inventory") then
|
if minetest.get_modpath("mcl_inventory") then
|
||||||
mcl_inventory.update_inventory_formspec(player)
|
mcl_inventory.update_inventory_formspec(player)
|
||||||
end
|
end
|
||||||
|
minetest.log("action", "[mcl_skins] Player skin for "..playername.." set to skin #"..skin_id)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -98,8 +99,13 @@ minetest.register_on_joinplayer(function(player)
|
||||||
set_skin = math.random(0, mcl_skins.skin_count)
|
set_skin = math.random(0, mcl_skins.skin_count)
|
||||||
end
|
end
|
||||||
if set_skin then
|
if set_skin then
|
||||||
|
local ok = mcl_skins.set_player_skin(player, set_skin)
|
||||||
|
if not ok then
|
||||||
|
set_skin = math.random(0, mcl_skins.skin_count)
|
||||||
|
minetest.log("warning", "[mcl_skins] Player skin for "..name.." not found, falling back to skin #"..set_skin)
|
||||||
mcl_skins.set_player_skin(player, set_skin)
|
mcl_skins.set_player_skin(player, set_skin)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- command to set player skin (usually for custom skins)
|
-- command to set player skin (usually for custom skins)
|
||||||
|
@ -148,3 +154,5 @@ minetest.register_chatcommand("setskin", {
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.log("action", "[mcl_skins] Mod initialized with "..mcl_skins.skin_count.." custom skin(s)")
|
||||||
|
|
Loading…
Reference in New Issue