From 918c408e4dc8fa77155753a1e2802140321e9420 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 5 Mar 2019 14:26:44 +0100 Subject: [PATCH] mcl_skins now obeys file name conventions --- mods/PLAYER/mcl_skins/init.lua | 17 +++++++++++------ .../{character.txt => mcl_skins_character.txt} | 0 ...aracter_1.txt => mcl_skins_character_1.txt} | 0 ...aracter_1.png => mcl_skins_character_1.png} | Bin .../{player_1.png => mcl_skins_player_1.png} | Bin ...er_dummy.png => mcl_skins_player_dummy.png} | Bin 6 files changed, 11 insertions(+), 6 deletions(-) rename mods/PLAYER/mcl_skins/meta/{character.txt => mcl_skins_character.txt} (100%) rename mods/PLAYER/mcl_skins/meta/{character_1.txt => mcl_skins_character_1.txt} (100%) rename mods/PLAYER/mcl_skins/textures/{character_1.png => mcl_skins_character_1.png} (100%) rename mods/PLAYER/mcl_skins/textures/{player_1.png => mcl_skins_player_1.png} (100%) rename mods/PLAYER/mcl_skins/textures/{player_dummy.png => mcl_skins_player_dummy.png} (100%) diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index 53e73f97..f8bd8264 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -20,8 +20,8 @@ while true do skin = "character" mcl_skins.has_preview[id] = true else - skin = "character_" .. id - local preview = "player_" .. id + skin = "mcl_skins_character_" .. id + local preview = "mcl_skins_player_" .. id -- Does skin file exist? f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png") @@ -46,7 +46,12 @@ while true do mcl_skins.list[id] = skin -- does metadata exist for that skin file ? - f = io.open(mcl_skins.modpath .. "/meta/" .. skin .. ".txt") + if id == 0 then + metafile = "mcl_skins_character.txt" + else + metafile = "mcl_skins_character_"..id..".txt" + end + f = io.open(mcl_skins.modpath .. "/meta/" .. metafile) if f then data = minetest.deserialize("return {" .. f:read('*all') .. "}") @@ -89,12 +94,12 @@ mcl_skins.set_player_skin = function(player, skin_id) skin = "character" preview = "player" else - skin = "character_" .. tostring(skin_id) + skin = "mcl_skins_character_" .. tostring(skin_id) if mcl_skins.has_preview[skin_id] then - preview = "player_" .. tostring(skin_id) + preview = "mcl_skins_player_" .. tostring(skin_id) else -- Fallback preview image if preview image is missing - preview = "player_dummy" + preview = "mcl_skins_player_dummy" end end skin_file = skin .. ".png" diff --git a/mods/PLAYER/mcl_skins/meta/character.txt b/mods/PLAYER/mcl_skins/meta/mcl_skins_character.txt similarity index 100% rename from mods/PLAYER/mcl_skins/meta/character.txt rename to mods/PLAYER/mcl_skins/meta/mcl_skins_character.txt diff --git a/mods/PLAYER/mcl_skins/meta/character_1.txt b/mods/PLAYER/mcl_skins/meta/mcl_skins_character_1.txt similarity index 100% rename from mods/PLAYER/mcl_skins/meta/character_1.txt rename to mods/PLAYER/mcl_skins/meta/mcl_skins_character_1.txt diff --git a/mods/PLAYER/mcl_skins/textures/character_1.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_character_1.png similarity index 100% rename from mods/PLAYER/mcl_skins/textures/character_1.png rename to mods/PLAYER/mcl_skins/textures/mcl_skins_character_1.png diff --git a/mods/PLAYER/mcl_skins/textures/player_1.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_player_1.png similarity index 100% rename from mods/PLAYER/mcl_skins/textures/player_1.png rename to mods/PLAYER/mcl_skins/textures/mcl_skins_player_1.png diff --git a/mods/PLAYER/mcl_skins/textures/player_dummy.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_player_dummy.png similarity index 100% rename from mods/PLAYER/mcl_skins/textures/player_dummy.png rename to mods/PLAYER/mcl_skins/textures/mcl_skins_player_dummy.png