diff --git a/init.lua b/init.lua index f402437..621b7ff 100644 --- a/init.lua +++ b/init.lua @@ -69,7 +69,7 @@ maps.get_map_filename = function(map_id) return "maps_map_texture_" .. map_id .. ".tga" end -maps.create_map = function(pos) +maps.create_map_item = function(pos, draw_x) local itemstack = ItemStack("maps:map") local meta = itemstack:get_meta() @@ -82,8 +82,10 @@ maps.create_map = function(pos) local maxp = vector.add(minp, vector.new(size - 1, size - 1, size - 1)) meta:set_string("maps:maxp", minetest.pos_to_string(maxp)) - local xpos = vector.round(pos) - meta:set_string("maps:xpos", minetest.pos_to_string(xpos)) + if draw_x then + local xpos = vector.round(pos) + meta:set_string("maps:xpos", minetest.pos_to_string(xpos)) + end local filename = maps.get_map_filename(map_id) maps.work[map_id] = true @@ -733,19 +735,23 @@ minetest.register_globalstep( end ) -maps.create_map_item = function(itemstack, player, pointed_thing) - local pos = player:get_pos() - if pos then - local map = maps.create_map(pos) - return map - end -end - minetest.override_item( "map:mapping_kit", { - on_place = maps.create_map_item, - on_secondary_use = maps.create_map_item, + on_place = function(itemstack, player, pointed_thing) + local pos = pointed_thing.under + if pos then + local map = maps.create_map_item(pos, true) + return map + end + end, + on_secondary_use = function(itemstack, player, pointed_thing) + local pos = player:get_pos() + if pos then + local map = maps.create_map_item(pos, false) + return map + end + end, } )