forked from mtcontrib/ambience
		
	.06
Greatly increased variety and frequency of day birds. Increased frequency of owls at night.
This commit is contained in:
		@@ -1,6 +1,8 @@
 | 
			
		||||
local night = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="horned_owl", length=3},
 | 
			
		||||
	{name="horned_owl", length=3},
 | 
			
		||||
	{name="horned_owl", length=3},
 | 
			
		||||
	{name="Wolves_Howling", length=11}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -11,12 +13,16 @@ local night_frequent = {
 | 
			
		||||
 | 
			
		||||
local day = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="bird", length=30}
 | 
			
		||||
	{name="Best Cardinal Bird", length=4},
 | 
			
		||||
	{name="craw", length=3},
 | 
			
		||||
	{name="bluejay", length=18}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local day_frequent = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="", length=0}
 | 
			
		||||
	{name="robin2", length=43},
 | 
			
		||||
	{name="birdsongnl", length=72},
 | 
			
		||||
	{name="bird", length=30}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local cave = {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,54 +0,0 @@
 | 
			
		||||
local night = {"Crickets_At_NightCombo", "horned_owl", "Wolves_Howling"}
 | 
			
		||||
local day = {"bird"}
 | 
			
		||||
local cave = {"Bats_in_Cave","drippingwater_drip.1","drippingwater_drip.2","drippingwater_drip.3", "Single_Water_Droplet", "Spooky_Water_Drops"}
 | 
			
		||||
 | 
			
		||||
math.randomseed(3)
 | 
			
		||||
sound_playing = 0
 | 
			
		||||
 | 
			
		||||
minetest.register_globalstep(function(time)
 | 
			
		||||
		local time = minetest.env:get_timeofday()
 | 
			
		||||
	--	minetest.chat_send_all(time .. " " .. sound_playing)
 | 
			
		||||
 | 
			
		||||
		if sound_playing == 0 then
 | 
			
		||||
		sound_playing = time
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if sound_playing > 1 and time < 0.05 then
 | 
			
		||||
		sound_playing = 0.05
 | 
			
		||||
		end
 | 
			
		||||
		
 | 
			
		||||
		for _,player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
			if player:getpos().y < 0 then
 | 
			
		||||
				if math.random(10000) >9980 then
 | 
			
		||||
					minetest.sound_play(cave[math.random(1, #cave)], {to_player = player:get_player_name()})
 | 
			
		||||
				end
 | 
			
		||||
			else
 | 
			
		||||
				--random wolves & owls at night
 | 
			
		||||
				if time > 0.8 or time < 0.2 then
 | 
			
		||||
					if math.random(10000) >9997 then
 | 
			
		||||
					 	minetest.sound_play("Wolves_Howling")
 | 
			
		||||
					end		 	
 | 
			
		||||
					if math.random(10000) >9997 then
 | 
			
		||||
					 	minetest.sound_play("horned_owl")
 | 
			
		||||
					end	
 | 
			
		||||
				end	
 | 
			
		||||
				
 | 
			
		||||
				if time > sound_playing then
 | 
			
		||||
					if time > 0.8 or time < 0.2 then
 | 
			
		||||
						sound_playing = time + 0.07
 | 
			
		||||
						minetest.sound_play("Crickets_At_NightCombo")
 | 
			
		||||
						return true
 | 
			
		||||
				end	
 | 
			
		||||
				sound_playing = time + 0.1
 | 
			
		||||
				minetest.sound_play("bird")
 | 
			
		||||
				return true
 | 
			
		||||
				end
 | 
			
		||||
					
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
end)
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
-- ***********************************************************************************
 | 
			
		||||
--													   ***********************************************
 | 
			
		||||
--					Ambience							**************************************************
 | 
			
		||||
--													   ***********************************************
 | 
			
		||||
-- ***********************************************************************************
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
BIRDS = true
 | 
			
		||||
 | 
			
		||||
-- ***********************************************************************************
 | 
			
		||||
--		BIRDS 			**************************************************
 | 
			
		||||
-- ***********************************************************************************
 | 
			
		||||
if BIRDS == true then
 | 
			
		||||
	local bird = {}
 | 
			
		||||
	bird.sounds = {}
 | 
			
		||||
	bird_sound = function(p)
 | 
			
		||||
				local wanted_sound = {name="bird", gain=0.6}
 | 
			
		||||
				bird.sounds[minetest.hash_node_position(p)] = {
 | 
			
		||||
					handle = minetest.sound_play(wanted_sound, {pos=p, loop=true}),
 | 
			
		||||
					name = wanted_sound.name, }
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
	bird_stop = function(p)
 | 
			
		||||
				local sound = bird.sounds[minetest.hash_node_position(p)]
 | 
			
		||||
				if sound ~= nil then
 | 
			
		||||
					minetest.sound_stop(sound.handle)
 | 
			
		||||
					bird.sounds[minetest.hash_node_position(p)] = nil
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
	minetest.register_on_dignode(function(p, node)
 | 
			
		||||
		if node.name == "4seasons:bird" then
 | 
			
		||||
			bird_stop(p)
 | 
			
		||||
 | 
			
		||||
		end
 | 
			
		||||
	end)
 | 
			
		||||
	minetest.register_abm({
 | 
			
		||||
			nodenames = { "4seasons:leaves_spring",'default:leaves' },
 | 
			
		||||
			interval = NATURE_GROW_INTERVAL,
 | 
			
		||||
			chance = 200,
 | 
			
		||||
			action = function(pos, node, active_object_count, active_object_count_wider)
 | 
			
		||||
				local air = { x=pos.x, y=pos.y+1,z=pos.z }
 | 
			
		||||
				local is_air = minetest.env:get_node_or_nil(air)
 | 
			
		||||
				if is_air ~= nil and is_air.name == 'air' then
 | 
			
		||||
					minetest.env:add_node(air,{type="node",name='4seasons:bird'})
 | 
			
		||||
					bird_sound(air)
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
	})
 | 
			
		||||
	minetest.register_abm({
 | 
			
		||||
			nodenames = {'4seasons:bird' },
 | 
			
		||||
			interval = NATURE_GROW_INTERVAL,
 | 
			
		||||
			chance = 2,
 | 
			
		||||
			action = function(pos, node, active_object_count, active_object_count_wider)
 | 
			
		||||
				minetest.env:remove_node(pos)
 | 
			
		||||
				bird_stop(pos)
 | 
			
		||||
			end
 | 
			
		||||
	})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,154 +0,0 @@
 | 
			
		||||
local night = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="horned_owl", length=3},
 | 
			
		||||
	{name="Wolves_Howling", length=11}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local night_frequent = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="Crickets_At_NightCombo", length=69}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local day = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="bird", length=30}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local day_frequent = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="", length=0}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local cave = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="Bats_in_Cave", length=5}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local cave_frequent = {
 | 
			
		||||
	handler = {},
 | 
			
		||||
	{name="dippingwater_drip", length=2},
 | 
			
		||||
	{name="Single_Water_Droplet", length=3},
 | 
			
		||||
	{name="Spooky_Water_Drops", length=7}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- 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()
 | 
			
		||||
	if list.handler[player_name] == nil then
 | 
			
		||||
		local handler = minetest.sound_play(list[number].name, {to_player=player_name})
 | 
			
		||||
		if handler ~= nil then
 | 
			
		||||
			list.handler[player_name] = handler
 | 
			
		||||
			minetest.after(list[number].length, function(args)
 | 
			
		||||
				local list = args[1]
 | 
			
		||||
				local player_name = args[2]
 | 
			
		||||
				minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
				list.handler[player_name] = nil
 | 
			
		||||
			end, {list, player_name})
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- stops all sounds that are not in still_playing
 | 
			
		||||
local stop_sound = function(still_playing, player)
 | 
			
		||||
	local player_name = player:get_player_name()
 | 
			
		||||
	if still_playing.cave == nil then
 | 
			
		||||
		local list = cave
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if still_playing.cave_frequent == nil then
 | 
			
		||||
		local list = cave_frequent
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if still_playing.night == nil then
 | 
			
		||||
		local list = night
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if still_playing.night_frequent == nil then
 | 
			
		||||
		local list = night_frequent
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if still_playing.day == nil then
 | 
			
		||||
		local list = day
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if still_playing.day_frequent == nil then
 | 
			
		||||
		local list = day_frequent
 | 
			
		||||
		if list.handler[player_name] ~= nil then
 | 
			
		||||
			minetest.sound_stop(list.handler[player_name])
 | 
			
		||||
			list.handler[player_name] = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local timer = 0
 | 
			
		||||
minetest.register_globalstep(function(dtime)
 | 
			
		||||
	timer = timer+dtime
 | 
			
		||||
	if timer < 5 then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	timer = 0
 | 
			
		||||
	-- normal sounds
 | 
			
		||||
	if math.random(1, 100) <= 5 then
 | 
			
		||||
		if  minetest.env:get_timeofday() < 0.2 or  minetest.env:get_timeofday() > 0.8 then
 | 
			
		||||
			for _,player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
				if player:getpos().y < 0 then
 | 
			
		||||
					stop_sound({cave=true, cave_frequent=true}, player)
 | 
			
		||||
					play_sound(player, cave, math.random(1, #cave))
 | 
			
		||||
				else
 | 
			
		||||
					stop_sound({night=true, night_frequent=true}, player)
 | 
			
		||||
					play_sound(player, night, math.random(1, #night))
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		else
 | 
			
		||||
			for _,player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
				if player:getpos().y < 0 then
 | 
			
		||||
					stop_sound({cave=true, cave_frequent=true}, player)
 | 
			
		||||
					play_sound(player, cave, math.random(1, #cave))
 | 
			
		||||
				else
 | 
			
		||||
					stop_sound({day=true, day_frequent=true}, player)
 | 
			
		||||
					play_sound(player, day, math.random(1, #day))
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- frequent sounds
 | 
			
		||||
	if math.random(1, 100) <= 50 then
 | 
			
		||||
		if  minetest.env:get_timeofday() < 0.2 or  minetest.env:get_timeofday() > 0.8 then
 | 
			
		||||
			for _,player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
				if player:getpos().y < 0 then
 | 
			
		||||
					stop_sound({cave=true, cave_frequent=true}, player)
 | 
			
		||||
					play_sound(player, cave_frequent, math.random(1, #cave_frequent))
 | 
			
		||||
				else
 | 
			
		||||
					stop_sound({night=true, night_frequent=true}, player)
 | 
			
		||||
					play_sound(player, night_frequent, math.random(1, #night_frequent))
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		else
 | 
			
		||||
			for _,player in ipairs(minetest.get_connected_players()) do
 | 
			
		||||
				if player:getpos().y < 0 then
 | 
			
		||||
					stop_sound({cave=true, cave_frequent=true}, player)
 | 
			
		||||
					play_sound(player, cave_frequent, math.random(1, #cave_frequent))
 | 
			
		||||
				else
 | 
			
		||||
					stop_sound({day=true, day_frequent=true}, player)
 | 
			
		||||
					play_sound(player, day_frequent, math.random(1, #day_frequent))
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end)
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/Best Cardinal Bird.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/Best Cardinal Bird.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/Hollow_Wind.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/Hollow_Wind.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -10,3 +10,22 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Single Water Droplet Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/384-Single-Water-Droplet.html
 | 
			
		||||
 | 
			
		||||
--HollowWind, Black Boe, Creative Commons 0 License, http://www.freesound.org/people/Black%20Boe/sounds/22331/
 | 
			
		||||
 | 
			
		||||
--drippingwater*.ogg sounds: CC0, Dripping Water Mod, by kddekadenz, http://minetest.net/forum/viewtopic.php?id=1688
 | 
			
		||||
 | 
			
		||||
--best cardinal bird: License: Attribution 3.0 | Recorded by PsychoBird,  http://soundbible.com/1515-Best-Cardinal-Bird.html
 | 
			
		||||
 | 
			
		||||
--birdsongnl: the Attribution License, HerbertBoland, http://www.freesound.org/people/HerbertBoland/sounds/28312/  (end)
 | 
			
		||||
 | 
			
		||||
--robin2:  Attribution License, reinsamba, http://www.freesound.org/people/reinsamba/sounds/32479/  (end)
 | 
			
		||||
 | 
			
		||||
--Craw.WAV, Attribution License, inchadney, http://www.freesound.org/people/inchadney/sounds/52450/
 | 
			
		||||
 | 
			
		||||
--bluejay.wav,  Creative Commons 0 License,  UncleSigmund, http://www.freesound.org/people/UncleSigmund/sounds/42382/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--natural night sounds in Boquete.wav,  Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/15851/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/birdsongnl.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/birdsongnl.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/bluejay.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/bluejay.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/craw.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/craw.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								ambience/sounds/robin2.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ambience/sounds/robin2.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user