forked from mtcontrib/minetest_returnmirror
Add basic sounds
This commit is contained in:
parent
425d355b0b
commit
f6b9b5d1bf
15
init.lua
15
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
|
||||
})
|
||||
|
BIN
sounds/returnmirror_set.ogg
Normal file
BIN
sounds/returnmirror_set.ogg
Normal file
Binary file not shown.
BIN
sounds/returnmirror_teleport.ogg
Normal file
BIN
sounds/returnmirror_teleport.ogg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user