diff --git a/items.lua b/items.lua index 8bf1516..772c50c 100644 --- a/items.lua +++ b/items.lua @@ -16,9 +16,11 @@ local function map_from_meta(meta, player_x, player_y) return id; end +-- The map item/node minetest.register_node("cartographer:map", { description = "Map", inventory_image = "cartographer_map.png", + tiles = { "cartographer_map.png" }, drawtype = "signlike", paramtype = "light", paramtype2 = "wallmounted", @@ -43,14 +45,19 @@ minetest.register_node("cartographer:map", { return stack; end, - after_place_node = function(stack, placer, pointed_thing) + -- Called when this node is placed in the world. Copies map data from the + -- item to the node. + -- pos: The position of the node + -- placer: The object that placed this node (can be nil) + -- stack: The itemstack that was placed + -- pointed_thing: The current pointed thing + after_place_node = function(pos, placer, stack, pointed_thing) local meta = stack:get_meta():to_table(); - local s = minetest.item_place(stack, placer, pointed_thing); - - local node_meta = minetest.get_meta(pointed_thing); + local node_meta = minetest.get_meta(pos); node_meta:from_table(meta); - return nil; + -- Consume the item after placing + return false; end, on_rightclick = function(pos, node, player, itemstack, pointed_thing) diff --git a/map_formspec.lua b/map_formspec.lua index 5e4aeaf..b6c8348 100644 --- a/map_formspec.lua +++ b/map_formspec.lua @@ -13,7 +13,7 @@ local map_formspec_prefix = [[ ]]; local tile = "image[%f,%f;%f,%f;%s]"; -local marker = "animated_image[%f,%f;%f,%f;%s:%d,%d]"; +local marker = "animated_image[%f,%f;%f,%f;;%s;%d;%d]"; local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_scale, is_visible, get_marker, user) local str = ""; diff --git a/textures/cartographer_map.png b/textures/cartographer_map.png new file mode 100644 index 0000000..afd2f42 Binary files /dev/null and b/textures/cartographer_map.png differ