Add basic sounds

This commit is contained in:
Wuzzy 2015-02-13 23:21:25 +01:00
parent 425d355b0b
commit f6b9b5d1bf
3 changed files with 10 additions and 5 deletions

View File

@ -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
})

BIN
sounds/returnmirror_set.ogg Normal file

Binary file not shown.

Binary file not shown.