diff --git a/init.lua b/init.lua index 4de2f02..bc663d2 100644 --- a/init.lua +++ b/init.lua @@ -8,16 +8,21 @@ minetest.register_tool("returnmirror:returnmirror", { wield_image = "returnmirror_returnmirror.png", tool_capabilities = {}, on_use = function(itemstack, user, pointed_thing) - local pos_string = itemstack:get_metadata() - local pos = minetest.string_to_pos(pos_string) - if pos ~= nil then + local dest_string = itemstack:get_metadata() + local dest = minetest.string_to_pos(dest_string) + if dest ~= nil then if mana.subtract(user:get_player_name(), returnmirror.cost) then - user:setpos(pos) + 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}) end end end, on_place = function(itemstack, placer, pointed_thing) - itemstack:set_metadata(minetest.pos_to_string(placer:getpos())) + 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}) return itemstack end }) diff --git a/sounds/returnmirror_set.ogg b/sounds/returnmirror_set.ogg new file mode 100644 index 0000000..0335350 Binary files /dev/null and b/sounds/returnmirror_set.ogg differ diff --git a/sounds/returnmirror_teleport.ogg b/sounds/returnmirror_teleport.ogg new file mode 100644 index 0000000..4886853 Binary files /dev/null and b/sounds/returnmirror_teleport.ogg differ