Added a return code to load_maps
Added a return code to load_maps to check for if dynamic_add_media registers a fail. Used by mcl_itemframes when reloading a map placed into an itemframe.
This commit is contained in:
parent
1f5b92f7bf
commit
6d1b1b3c74
|
@ -22,6 +22,9 @@ local map_textures_path = worldpath .. "/mcl_maps/"
|
|||
|
||||
minetest.mkdir(map_textures_path)
|
||||
|
||||
-- overwrite the builtin tga_encoder
|
||||
dofile(modpath .. "/tga_encoder_init.lua")
|
||||
|
||||
local function load_json_file(name)
|
||||
local file = assert(io.open(modpath .. "/" .. name .. ".json", "r"))
|
||||
local data = minetest.parse_json(file:read())
|
||||
|
@ -141,30 +144,43 @@ end
|
|||
|
||||
function mcl_maps.load_map(id, callback)
|
||||
if id == "" or creating_maps[id] then
|
||||
return
|
||||
return false
|
||||
end
|
||||
|
||||
local texture = "mcl_maps_map_texture_" .. id .. ".tga"
|
||||
|
||||
local result = true
|
||||
|
||||
if not loaded_maps[id] then
|
||||
if not minetest.features.dynamic_add_media_table then
|
||||
-- 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)
|
||||
if callback then callback(texture) end
|
||||
result = dynamic_add_media(map_textures_path .. texture, function()
|
||||
end)
|
||||
if callback then
|
||||
callback(texture)
|
||||
end
|
||||
else
|
||||
-- minetest.dynamic_add_media() never blocks
|
||||
-- in Minetest 5.5, callback runs after load
|
||||
dynamic_add_media(map_textures_path .. texture, function()
|
||||
result = dynamic_add_media(map_textures_path .. texture, function()
|
||||
loaded_maps[id] = true
|
||||
if callback then callback(texture) end
|
||||
if callback then
|
||||
callback(texture)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if result == false then
|
||||
return false
|
||||
end
|
||||
|
||||
if loaded_maps[id] then
|
||||
if callback then callback(texture) end
|
||||
if callback then
|
||||
callback(texture)
|
||||
end
|
||||
return texture
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user