diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..95db00e --- /dev/null +++ b/init.lua @@ -0,0 +1,181 @@ +local night = { + handler = {}, + {name="horned_owl", length=3}, + {name="horned_owl", length=3}, + {name="horned_owl", length=3}, + {name="Wolves_Howling", length=11} +} + +local night_frequent = { + handler = {}, + {name="Crickets_At_NightCombo", length=69} +} + +local day = { + handler = {}, + {name="Best Cardinal Bird", length=4}, + {name="craw", length=3}, + {name="bluejay", length=18} +} + +local day_frequent = { + handler = {}, + {name="robin2", length=43}, + {name="birdsongnl", length=72}, + {name="bird", length=30} +} + +local cave = { + handler = {}, + {name="Bats_in_Cave", length=5} +} + +local cave_frequent = { + handler = {}, + {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() + 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] + if list.handler[player_name] ~= nil then + minetest.sound_stop(list.handler[player_name]) + list.handler[player_name] = nil + end + 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 + + -- 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, {gain=0.3}) + music.handler = nil + end + end, music.handler) + end +end) diff --git a/sounds/Bats_in_Cave.ogg b/sounds/Bats_in_Cave.ogg new file mode 100644 index 0000000..97662d0 Binary files /dev/null and b/sounds/Bats_in_Cave.ogg differ diff --git a/sounds/Best Cardinal Bird.ogg b/sounds/Best Cardinal Bird.ogg new file mode 100644 index 0000000..876325f Binary files /dev/null and b/sounds/Best Cardinal Bird.ogg differ diff --git a/sounds/Crickets_At_NightCombo.ogg b/sounds/Crickets_At_NightCombo.ogg new file mode 100644 index 0000000..8487d8d Binary files /dev/null and b/sounds/Crickets_At_NightCombo.ogg differ diff --git a/sounds/Hollow_Wind.ogg b/sounds/Hollow_Wind.ogg new file mode 100644 index 0000000..39d7e93 Binary files /dev/null and b/sounds/Hollow_Wind.ogg differ diff --git a/sounds/Single_Water_Droplet.ogg b/sounds/Single_Water_Droplet.ogg new file mode 100644 index 0000000..fd4a91c Binary files /dev/null and b/sounds/Single_Water_Droplet.ogg differ diff --git a/sounds/SoundLicenses.txt b/sounds/SoundLicenses.txt new file mode 100644 index 0000000..2a853bf --- /dev/null +++ b/sounds/SoundLicenses.txt @@ -0,0 +1,31 @@ +--Nightime Sound, Recorded by Mike Koenig, License: Attribution 3.0 http://soundbible.com/951-Nightime.html +--Crickets At Night Sound, License: Attribution 3.0 | Recorded by Mike Koenig |http://soundbible.com/365-Crickets-At-Night.html + +--Medium Pack Of Wolves Howling, License: Public Domain | Recorded by fws.gov, http://soundbible.com/277-Medium-Pack-Of-Wolves-Howling.html + +--Horned Owl Sound, License: Attribution 3.0 | Recorded by Mike Koenig , http://soundbible.com/1851-Horned-Owl.html +--Bats In Cave Sound, License: Attr-Noncommercial 3.0 | Recorded by Mike Koenig , http://soundbible.com/1939-Bats-In-Cave.html + +--Spooky Water Drops Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/380-Spooky-Water-Drops.html + + +-- 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/ + + diff --git a/sounds/Spooky_Water_Drops.ogg b/sounds/Spooky_Water_Drops.ogg new file mode 100644 index 0000000..c2a3be9 Binary files /dev/null and b/sounds/Spooky_Water_Drops.ogg differ diff --git a/sounds/Wolves_Howling.ogg b/sounds/Wolves_Howling.ogg new file mode 100644 index 0000000..537d057 Binary files /dev/null and b/sounds/Wolves_Howling.ogg differ diff --git a/sounds/bird.ogg b/sounds/bird.ogg new file mode 100644 index 0000000..af705f5 Binary files /dev/null and b/sounds/bird.ogg differ diff --git a/sounds/birdsongnl.ogg b/sounds/birdsongnl.ogg new file mode 100644 index 0000000..6cbd85a Binary files /dev/null and b/sounds/birdsongnl.ogg differ diff --git a/sounds/bluejay.ogg b/sounds/bluejay.ogg new file mode 100644 index 0000000..a50675d Binary files /dev/null and b/sounds/bluejay.ogg differ diff --git a/sounds/craw.ogg b/sounds/craw.ogg new file mode 100644 index 0000000..6474b68 Binary files /dev/null and b/sounds/craw.ogg differ diff --git a/sounds/drippingwater_drip_a.ogg b/sounds/drippingwater_drip_a.ogg new file mode 100644 index 0000000..84c3e01 Binary files /dev/null and b/sounds/drippingwater_drip_a.ogg differ diff --git a/sounds/drippingwater_drip_b.ogg b/sounds/drippingwater_drip_b.ogg new file mode 100644 index 0000000..18790fc Binary files /dev/null and b/sounds/drippingwater_drip_b.ogg differ diff --git a/sounds/drippingwater_drip_c.ogg b/sounds/drippingwater_drip_c.ogg new file mode 100644 index 0000000..f367406 Binary files /dev/null and b/sounds/drippingwater_drip_c.ogg differ diff --git a/sounds/horned_owl.ogg b/sounds/horned_owl.ogg new file mode 100644 index 0000000..f30d0b3 Binary files /dev/null and b/sounds/horned_owl.ogg differ diff --git a/sounds/mtest.ogg b/sounds/mtest.ogg new file mode 100644 index 0000000..da84263 Binary files /dev/null and b/sounds/mtest.ogg differ diff --git a/sounds/robin2.ogg b/sounds/robin2.ogg new file mode 100644 index 0000000..13e95e2 Binary files /dev/null and b/sounds/robin2.ogg differ