Suppress building placeholder if preview image not available

master
Jordan Irwin 2021-08-12 15:56:28 -07:00
parent b7990b9982
commit be573a9b13
3 changed files with 14 additions and 1 deletions

View File

@ -5,6 +5,7 @@ next
- added localization support
- added Spanish translation
- skins are unregistered if their textures aren't cached
- suppresses building placeholder if preview image isn't available
v1.4

View File

@ -62,7 +62,11 @@ function wardrobe.show_formspec(player, page)
formspec = formspec
.. "button_exit[" .. border_l .. "," .. addon+.5 ..";5,1;s:" .. s[1] .. ";" .. s[2] .. "]"
.. "image[" .. border_l+5 .. "," .. addon .. ";1,2;" .. preview .."]"
if wardrobe.cached_previews[s[1]] then
formspec = formspec
.. "image[" .. border_l+5 .. "," .. addon .. ";1,2;" .. preview .."]"
end
addon = addon + 2
end

View File

@ -11,6 +11,9 @@ wardrobe.playerSkins = {}
wardrobe.use_3d_armor = core.get_modpath("3d_armor") ~= nil and core.global_exists("armor")
-- suppresses showing preview if not cached
wardrobe.cached_previews = {}
function wardrobe.log(lvl, msg)
if not msg then
msg = lvl
@ -66,6 +69,11 @@ core.register_on_mods_loaded(function()
wardrobe.skinNames[skin] = nil
wardrobe.skin_count = wardrobe.skin_count-1
end
local preview = skin:gsub("%.png$", "-preview.png")
if cached_textures[preview] then
wardrobe.cached_previews[skin] = true
end
end
cached_textures = nil