From 7bb3b544e2d398764a82ac00fafc4665bbaa1a22 Mon Sep 17 00:00:00 2001 From: Hugues Ross Date: Fri, 20 Mar 2020 08:01:43 -0400 Subject: [PATCH] Bugfixes - Fix crash on map placement - Add temp map texture - Fix player marker on map --- items.lua | 17 ++++++++++++----- map_formspec.lua | 2 +- textures/cartographer_map.png | Bin 0 -> 1067 bytes 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 textures/cartographer_map.png 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 0000000000000000000000000000000000000000..afd2f4210578cebbb666537e3bdba65c662cc884 GIT binary patch literal 1067 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl4m>B|mLR=^3x;BT|Rl8efdReV) zj@&!55U2nT*jbr=e`WRCqqF5zjqxZOl^P9!!5jj)xw)%Wt@{7}zsA?LQ$UA`lmz(& z1G(sc!QcP6AW)va#5JNMI6tkVJh3R1!M!Lkt-@%*qTno`lt*%rUpkOxGO!1c4*noA zARa^}!Uz?Ag{3KYZ%3$eIbhk%j?z5ll7C#$K>Re>Vk9T6^c)+(M zmD%BJ#p2f+X6{wAK4tRYg3j94j~Cj{mDgQ=Y$kj4Cc)dShL;V2Rxo(F`njxgN@xNA DyUu*v literal 0 HcmV?d00001