Fix copied maps not retaining marker information

This commit is contained in:
Hugues Ross 2020-04-11 15:36:15 -04:00
parent 0f706533b6
commit 4cc3a4cfaa
2 changed files with 7 additions and 1 deletions

View File

@ -149,6 +149,10 @@ function cartographer.create_map_item(size, detail, scale)
return map;
end
-- Create a copy of the given map
-- stack: An itemstack containing a map
--
-- Returns an itemstack with the copied map
function cartographer.copy_map_item(stack)
local meta = stack:get_meta();
@ -169,6 +173,9 @@ function cartographer.copy_map_item(stack)
for k,v in pairs(src.fill) do
dest.fill[k] = v;
end
for k,v in pairs(src.markers) do
dest.markers[k] = v;
end
copy_meta:set_int("cartographer:map_id", new_id);
copy_meta:set_string("description", "Map #" .. tostring(new_id) .. "\n[" .. tostring(fromchunk(dest.x)) .. "," .. tostring(fromchunk(dest.z)) .. "] - [" .. tostring(fromchunk(dest.x + dest.w)) .. "," .. tostring(fromchunk(dest.z + dest.h)) .. "]")

View File

@ -415,7 +415,6 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
inv:set_stack("copy_output", 1, cartographer.copy_map_item(in_stack));
end
end
table_formspec(player:get_player_name(), 3)