From 62eaf60938e4b1f7c28db6b76143498911b82ea0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 5 Mar 2019 10:57:57 +0100 Subject: [PATCH] mcl_skins: Add fallback code if skin was missing --- mods/PLAYER/mcl_skins/init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index b584130c2..a822218d2 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -73,6 +73,7 @@ mcl_skins.set_player_skin = function(player, skin_id) if minetest.get_modpath("mcl_inventory") then mcl_inventory.update_inventory_formspec(player) end + minetest.log("action", "[mcl_skins] Player skin for "..playername.." set to skin #"..skin_id) return true end @@ -98,7 +99,12 @@ minetest.register_on_joinplayer(function(player) set_skin = math.random(0, mcl_skins.skin_count) end if set_skin then - mcl_skins.set_player_skin(player, set_skin) + 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) + end end end) @@ -148,3 +154,5 @@ minetest.register_chatcommand("setskin", { end, }) + +minetest.log("action", "[mcl_skins] Mod initialized with "..mcl_skins.skin_count.." custom skin(s)")