From 425d355b0ba523238eac36bc4466b07aec14601b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 13 Feb 2015 23:07:54 +0100 Subject: [PATCH] Save home point in mirror's meta data --- init.lua | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index 6f81bda..4de2f02 100644 --- a/init.lua +++ b/init.lua @@ -1,16 +1,5 @@ returnmirror = {} returnmirror.cost = 100 -returnmirror.file = minetest.get_worldpath() .. "/returnmirror.mt" - -returnmirror.write = function() - -end - - -returnmirror.load = function() - -end - minetest.register_tool("returnmirror:returnmirror", { description = "Mirror of Returning", @@ -19,9 +8,16 @@ minetest.register_tool("returnmirror:returnmirror", { wield_image = "returnmirror_returnmirror.png", tool_capabilities = {}, on_use = function(itemstack, user, pointed_thing) - if mana.subtract(user:get_player_name(), returnmirror.cost) then - user:setpos({x=0, y=0, z=0}) - return nil + local pos_string = itemstack:get_metadata() + local pos = minetest.string_to_pos(pos_string) + if pos ~= nil then + if mana.subtract(user:get_player_name(), returnmirror.cost) then + user:setpos(pos) + end end end, + on_place = function(itemstack, placer, pointed_thing) + itemstack:set_metadata(minetest.pos_to_string(placer:getpos())) + return itemstack + end })