diff --git a/init.lua b/init.lua index a7380bd..45fdc24 100644 --- a/init.lua +++ b/init.lua @@ -36,6 +36,8 @@ returnmirror.set_position_inactive = function(itemstack, user, pointed_thing) newitem:set_metadata(minetest.pos_to_string(pos)) minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12}) return newitem + else + minetest.sound_play( {name="returnmirror_fail", gain=1}, {pos=pos, max_hear_distance=18}) end end @@ -45,6 +47,8 @@ returnmirror.set_position_active = function(itemstack, user, pointed_thing) itemstack:set_metadata(minetest.pos_to_string(pos)) minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12}) return itemstack + else + minetest.sound_play( {name="returnmirror_fail", gain=1}, {pos=pos, max_hear_distance=18}) end end @@ -54,7 +58,9 @@ minetest.register_tool("returnmirror:mirror_inactive", { wield_image = "returnmirror_mirror_inactive.png", tool_capabilities = {}, range = 0, - on_use = function() end, + on_use = function(itemstack, user, pointed_thing) + minetest.sound_play( {name="returnmirror_fail", gain=1}, {pos=user:getpos(), max_hear_distance=18}) + end, on_place = returnmirror.set_position_inactive, on_secondary_use = returnmirror.set_position_inactive, }) @@ -69,8 +75,10 @@ minetest.register_tool("returnmirror:mirror_active", { on_use = function(itemstack, user, pointed_thing) local dest_string = itemstack:get_metadata() local dest = minetest.string_to_pos(dest_string) + local fail = true if dest ~= nil then if returnmirror.mana_check(user, returnmirror.cost_teleport) then + fail = false local src = user:getpos() minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=src, max_hear_distance=30}) minetest.add_particlespawner({ @@ -103,6 +111,9 @@ minetest.register_tool("returnmirror:mirror_active", { }) end end + if fail then + minetest.sound_play( {name="returnmirror_fail", gain=1}, {pos=pos, max_hear_distance=18}) + end end, on_place = returnmirror.set_position_active, on_secondary_use = returnmirror.set_position_active, diff --git a/sounds/returnmirror_fail.ogg b/sounds/returnmirror_fail.ogg new file mode 100644 index 0000000..55c45cc Binary files /dev/null and b/sounds/returnmirror_fail.ogg differ