Save home point in mirror's meta data

This commit is contained in:
Wuzzy 2015-02-13 23:07:54 +01:00
parent 2f265172d5
commit 425d355b0b

View File

@ -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
})