From 35ceb3ddf63b261bc83b8fd9e82d89a82ccdc8a0 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Sun, 7 May 2017 23:53:27 +0200 Subject: [PATCH] proper metadata handling. Preparation for destination in item name --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 4a625e5..be3ad0c 100644 --- a/init.lua +++ b/init.lua @@ -29,8 +29,12 @@ local function get_compass_stack(player, stack) local angle_dir = 90 - math.deg(dir) local angle_relative = (angle_north - angle_dir) % 360 local compass_image = math.floor((angle_relative/30) + 0.5)%12 + local meta = stack:get_metadata() - return "compass:"..compass_image.." 1 0 "..stack:get_metadata() + local newstack = ItemStack("compass:"..compass_image) + --meta:set_string("description", "Compass to "..minetest.pos_to_string(spawn)) -- does not work on stable 0.4.15 + newstack:set_metadata(meta) + return newstack end -- update inventory