-- sOUNDS :
-- https://freesound.org/people/HermanDV/sounds/327110/
-- https://freesound.org/people/vanishedillusion/sounds/500609/
btmt.sound_in_caves = core.settings:get_bool("sound_in_caves", false)

if btmt.sound_in_caves then 
local last_sound = 0
minetest.register_globalstep(function(dtime)
	local current_time = minetest.get_us_time()
	if current_time - last_sound >= 60 * (10^6)  then 
	   last_sound = current_time
		
		for _,player in ipairs(minetest.get_connected_players()) do
		        local player_name = player:get_player_name()
			local pos = player:get_pos()
			local sounds_cave  = {"cave_echo","rocks_falling_in_cave"}
			
			if pos.y < -10 then
				minetest.sound_play(sounds_cave[math.random(1,#sounds_cave)],{to_player = player_name,gain=1.0})
			end	
		end
	end	
	
end)
end
