Compare commits

...

3 Commits

8 changed files with 51 additions and 26 deletions

View File

@ -56,6 +56,11 @@ function mcl_maps.create_map(pos)
tt.reload_itemstack_description(itemstack)
creating_maps[id] = true
mcl_maps.draw_map(minp, maxp, id)
return itemstack
end
function mcl_maps.draw_map(minp, maxp, id)
minetest.emerge_area(minp, maxp, function(blockpos, action, calls_remaining)
if calls_remaining > 0 then
return
@ -144,41 +149,39 @@ function mcl_maps.create_map(pos)
tga_encoder.image(pixels):save(map_textures_path .. "mcl_maps_map_texture_" .. id .. ".tga")
creating_maps[id] = nil
end)
return itemstack
end
function mcl_maps.load_map(id, callback)
if id == "" or creating_maps[id] then
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
-- Attempt to load map texture image
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
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
result = dynamic_add_media(map_textures_path .. texture, function()
loaded_maps[id] = true
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
result = dynamic_add_media(map_textures_path .. texture, function()
loaded_maps[id] = true
if callback then
callback(texture)
end
end)
end
end)
end
if result == false then
-- Failed to load image
return false
end
@ -217,6 +220,26 @@ local function fill_map(itemstack, placer, pointed_thing)
end
end
local function refill_map(itemstack, placer, pointed_thing)
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
if minetest.settings:get_bool("enable_real_maps", true) then
local meta = itemstack:get_meta()
local id = meta:get_string("mcl_maps:id")
local minp = string_to_pos(meta:get_string("mcl_maps:minp"))
local maxp = string_to_pos(meta:get_string("mcl_maps:maxp"))
-- Re-draw the area in the map, and load the new image
mcl_maps.draw_map(minp, maxp, id)
mcl_maps.load_map(id)
return itemstack
end
end
minetest.register_craftitem("mcl_maps:empty_map", {
description = S("Empty Map"),
_doc_items_longdesc = S("Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used."),
@ -231,8 +254,10 @@ local filled_def = {
description = S("Map"),
_tt_help = S("Shows a map image."),
_doc_items_longdesc = S("When created, the map saves the nearby area as an image that can be viewed any time by holding the map."),
_doc_items_usagehelp = S("Hold the map in your hand. This will display a map on your screen."),
_doc_items_usagehelp = S("Hold the map in your hand. This will display a map on your screen. Rightclick to update the map."),
inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)",
on_place = refill_map,
on_secondary_use = refill_map,
stack_max = 64,
groups = { not_in_creative_inventory = 1, filled_map = 1, tool = 1 },
}

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=Rechtsklick,
Map=Karte
Shows a map image.=Zeigt ein Kartenbild.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Beim Erstellen speichert die Karte die Gegend in der Nähe als ein Bild, dass jederzeit durch halten der Karte angesehen werden kann.
Hold the map in your hand. This will display a map on your screen.=Halten Sie die Karte in Ihrer Hand. Eine Karte wird auf Ihrem Bildschirm angezeigt werden.
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=Halten Sie die Karte in Ihrer Hand. Eine Karte wird auf Ihrem Bildschirm angezeigt werden.

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=Clic droit p
Map=Carte
Shows a map image.=Affiche une carte.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Lors de sa création, la carte sauvegarde le terrain proche sous forme d'image qui peut être consultée n'importe quand en tenant la carte dans la main.
Hold the map in your hand. This will display a map on your screen.=Tenez la carte dans votre main. Cela affichera la carte à l'écran.
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=Tenez la carte dans votre main. Cela affichera la carte à l'écran.

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=右クリッ
Map=地図
Shows a map image.=地図画像を表示します。
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=作成すると、その付近の地図が画像として保存され、地図をかざすといつでも見ることができます。
Hold the map in your hand. This will display a map on your screen.=地図を手に持ってください。これで画面に地図が表示されます。
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=地図を手に持ってください。これで画面に地図が表示されます。

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=Kliknij praw
Map=Mapa
Shows a map image.=Pokazuje obraz mapy.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Gdy są utworzone mapy zapisują obszar okolicy jako obrazek, który może być oglądany przez trzymanie mapy w rękach.
Hold the map in your hand. This will display a map on your screen.=Weź mapę do ręki. To pokaże mapę na twoim ekranie.
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=Weź mapę do ręki. To pokaże mapę na twoim ekranie.

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=Clique com o
Map=Mapa
Shows a map image.=Mostra uma imagem do mapa.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Quando criado, o mapa salva a área próxima como uma imagem que pode ser visualizada sempre que você segurar o mapa.
Hold the map in your hand. This will display a map on your screen.=Segure o mapa em suas mãos. Isso mostrará um mapa em sua tela.
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=Segure o mapa em suas mãos. Isso mostrará um mapa em sua tela.

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=Правый
Map=Карта
Shows a map image.=Показать карту.
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=После создания карта сохраняет ближайшую местность которую можно посмотеть в любое время взяв карту в руки.
Hold the map in your hand. This will display a map on your screen.=Возьмите карту в руки. Так появится изображение карты на экране.
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=Возьмите карту в руки. Так появится изображение карты на экране.

View File

@ -5,4 +5,4 @@ Rightclick to create a filled map (which can't be stacked anymore).=
Map=
Shows a map image.=
When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=
Hold the map in your hand. This will display a map on your screen.=
Hold the map in your hand. This will display a map on your screen. Rightclick to update the map.=