mcl_skins: USe fallback if no preview img
This commit is contained in:
parent
35bafb2aeb
commit
9e84763478
|
@ -1,7 +1,7 @@
|
||||||
-- Skins for MineClone 2
|
-- Skins for MineClone 2
|
||||||
|
|
||||||
mcl_skins = {
|
mcl_skins = {
|
||||||
skins = {}, list = {}, previews = {}, meta = {},
|
skins = {}, list = {}, previews = {}, meta = {}, has_preview = {},
|
||||||
modpath = minetest.get_modpath("mcl_skins"),
|
modpath = minetest.get_modpath("mcl_skins"),
|
||||||
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,12 @@ while true do
|
||||||
|
|
||||||
if id == 0 then
|
if id == 0 then
|
||||||
skin = "character"
|
skin = "character"
|
||||||
|
mcl_skins.has_preview[id] = true
|
||||||
else
|
else
|
||||||
skin = "character_" .. id
|
skin = "character_" .. id
|
||||||
|
local preview = "player_" .. id
|
||||||
|
|
||||||
-- does skin file exist ?
|
-- Does skin file exist?
|
||||||
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
|
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
|
||||||
|
|
||||||
-- escape loop if not found
|
-- escape loop if not found
|
||||||
|
@ -29,6 +31,16 @@ while true do
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
-- Does skin preview file exist?
|
||||||
|
local file_preview = io.open(mcl_skins.modpath .. "/textures/" .. preview .. ".png")
|
||||||
|
if file_preview == nil then
|
||||||
|
minetest.log("warning", "[mcl_skins] Player skin #"..id.." does not have preview image (player_"..id..".png)")
|
||||||
|
mcl_skins.has_preview[id] = false
|
||||||
|
else
|
||||||
|
mcl_skins.has_preview[id] = true
|
||||||
|
file_preview:close()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_skins.list[id] = skin
|
mcl_skins.list[id] = skin
|
||||||
|
@ -78,7 +90,12 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
||||||
preview = "player"
|
preview = "player"
|
||||||
else
|
else
|
||||||
skin = "character_" .. tostring(skin_id)
|
skin = "character_" .. tostring(skin_id)
|
||||||
preview = "player_" .. tostring(skin_id)
|
if mcl_skins.has_preview[skin_id] then
|
||||||
|
preview = "player_" .. tostring(skin_id)
|
||||||
|
else
|
||||||
|
-- Fallback preview image if preview image is missing
|
||||||
|
preview = "player_dummy"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
skin_file = skin .. ".png"
|
skin_file = skin .. ".png"
|
||||||
mcl_skins.skins[playername] = skin
|
mcl_skins.skins[playername] = skin
|
||||||
|
|
BIN
mods/PLAYER/mcl_skins/textures/player_dummy.png
Normal file
BIN
mods/PLAYER/mcl_skins/textures/player_dummy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 982 B |
Loading…
Reference in New Issue
Block a user