forked from mtcontrib/minetest_returnmirror
Save home point in mirror's meta data
This commit is contained in:
parent
2f265172d5
commit
425d355b0b
24
init.lua
24
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
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user