Add support for music

master
PilzAdam 2012-08-18 21:04:22 +02:00
parent e26bb50359
commit eed7ef6473
3 changed files with 20 additions and 1 deletions

Binary file not shown.

View File

@ -26,11 +26,18 @@ local cave = {
local cave_frequent = {
handler = {},
{name="dippingwater_drip", length=2},
{name="drippingwater_drip_a", length=2},
{name="drippingwater_drip_b", length=2},
{name="drippingwater_drip_c", length=2},
{name="Single_Water_Droplet", length=3},
{name="Spooky_Water_Drops", length=7}
}
local music = {
handler = nil,
{name="mtest", length=4*60+33}
}
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
@ -153,4 +160,16 @@ minetest.register_globalstep(function(dtime)
end
end
end
-- music
if math.random(1, 100) <= 1 and music.handler == nil then
local track = music[math.random(1, #music)]
music.handler = minetest.sound_play(track.name)
minetest.after(track.length, function(handler)
if handler ~= nil then
minetest.sound_stop(handler)
music.handler = nil
end
end, music.handler)
end
end)

BIN
ambience/sounds/mtest.ogg Normal file

Binary file not shown.