forked from erle/xmaps
Properly update map item meta
This commit is contained in:
parent
6cb1b4cd64
commit
458e9dd87d
15
init.lua
15
init.lua
|
@ -456,10 +456,6 @@ maps.load_map_item = function(itemstack)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if maps.load[map_id] then
|
|
||||||
return maps.load_map(map_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
local texture_file_name = maps.get_map_filename(map_id)
|
local texture_file_name = maps.get_map_filename(map_id)
|
||||||
local texture_file_path = textures_dir .. texture_file_name
|
local texture_file_path = textures_dir .. texture_file_name
|
||||||
|
|
||||||
|
@ -522,7 +518,7 @@ maps.load_map_item = function(itemstack)
|
||||||
assert(
|
assert(
|
||||||
minetest.safe_file_write(
|
minetest.safe_file_write(
|
||||||
texture_file_path,
|
texture_file_path,
|
||||||
decode_item_meta(tga_deflate_base64)
|
maps.decode_map_item_meta(tga_deflate_base64)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
@ -534,7 +530,8 @@ maps.load_map_item = function(itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return maps.load_map(map_id)
|
local texture = maps.load_map(map_id)
|
||||||
|
return texture, itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(
|
minetest.register_on_joinplayer(
|
||||||
|
@ -558,7 +555,7 @@ minetest.register_on_joinplayer(
|
||||||
|
|
||||||
maps.show_map_hud = function(player)
|
maps.show_map_hud = function(player)
|
||||||
local wield_item = player:get_wielded_item()
|
local wield_item = player:get_wielded_item()
|
||||||
local texture = maps.load_map_item(wield_item)
|
local texture, updated_wield_item = maps.load_map_item(wield_item)
|
||||||
local player_pos = player:get_pos()
|
local player_pos = player:get_pos()
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
|
@ -580,6 +577,10 @@ maps.show_map_hud = function(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if updated_wield_item then
|
||||||
|
player:set_wielded_item(updated_wield_item)
|
||||||
|
end
|
||||||
|
|
||||||
local pos = vector.round(player_pos)
|
local pos = vector.round(player_pos)
|
||||||
local meta = wield_item:get_meta()
|
local meta = wield_item:get_meta()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue