2015-02-13 21:43:24 +01:00
|
|
|
returnmirror = {}
|
|
|
|
returnmirror.cost = 100
|
|
|
|
|
|
|
|
minetest.register_tool("returnmirror:returnmirror", {
|
|
|
|
description = "Mirror of Returning",
|
|
|
|
stack_max = 1,
|
|
|
|
inventory_image = "returnmirror_returnmirror.png",
|
|
|
|
wield_image = "returnmirror_returnmirror.png",
|
|
|
|
tool_capabilities = {},
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
2015-02-13 23:21:25 +01:00
|
|
|
local dest_string = itemstack:get_metadata()
|
|
|
|
local dest = minetest.string_to_pos(dest_string)
|
|
|
|
if dest ~= nil then
|
2015-02-13 23:07:54 +01:00
|
|
|
if mana.subtract(user:get_player_name(), returnmirror.cost) then
|
2015-02-13 23:21:25 +01:00
|
|
|
local src = user:getpos()
|
|
|
|
minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=src, max_hear_distance=30})
|
|
|
|
user:setpos(dest)
|
|
|
|
minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=dest, max_hear_distance=30})
|
2015-02-13 23:07:54 +01:00
|
|
|
end
|
2015-02-13 21:43:24 +01:00
|
|
|
end
|
|
|
|
end,
|
2015-02-13 23:07:54 +01:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2015-02-13 23:21:25 +01:00
|
|
|
local pos = placer:getpos()
|
|
|
|
itemstack:set_metadata(minetest.pos_to_string(pos))
|
|
|
|
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
|
2015-02-13 23:07:54 +01:00
|
|
|
return itemstack
|
|
|
|
end
|
2015-02-13 21:43:24 +01:00
|
|
|
})
|