Merge pull request 'Fix handheld maps not displaying in Minetest 5.5.0' (#2010) from fix-mcl-maps-in-minetest-5.5 into master

Reviewed-on: MineClone2/MineClone2#2010
This commit is contained in:
cora 2022-02-24 22:47:26 +00:00
commit 80c79dde1c
1 changed files with 15 additions and 3 deletions

View File

@ -147,11 +147,23 @@ function mcl_maps.load_map(id)
local texture = "mcl_maps_map_texture_" .. id .. ".tga" local texture = "mcl_maps_map_texture_" .. id .. ".tga"
if not loaded_maps[id] then if not loaded_maps[id] then
loaded_maps[id] = true if not minetest.features.dynamic_add_media_table then
dynamic_add_media(map_textures_path .. texture, function() end) -- minetest.dynamic_add_media() blocks in
-- Minetest 5.3 and 5.4 until media loads
loaded_maps[id] = true
dynamic_add_media(map_textures_path .. texture, function() end)
else
-- minetest.dynamic_add_media() never blocks
-- in Minetest 5.5, callback runs after load
dynamic_add_media(map_textures_path .. texture, function()
loaded_maps[id] = true
end)
end
end end
return texture if loaded_maps[id] then
return texture
end
end end
function mcl_maps.load_map_item(itemstack) function mcl_maps.load_map_item(itemstack)