Add failure sound

This commit is contained in:
Wuzzy 2016-08-08 07:20:44 +02:00
parent 1cf0aface5
commit 311207ec7c
2 changed files with 12 additions and 1 deletions

View File

@ -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,

Binary file not shown.