forked from mtcontrib/ambience
.07 music, water gasp! shortened bird songs
This commit is contained in:
parent
9ff5ed516b
commit
e54251ec80
BIN
ambience.zip
BIN
ambience.zip
Binary file not shown.
@ -1,18 +1,19 @@
|
|||||||
local night = {
|
local night = {
|
||||||
handler = {},
|
handler = {},
|
||||||
{name="horned_owl", length=3},
|
frequency = 10,
|
||||||
{name="horned_owl", length=3},
|
|
||||||
{name="horned_owl", length=3},
|
{name="horned_owl", length=3},
|
||||||
{name="Wolves_Howling", length=11}
|
{name="Wolves_Howling", length=11}
|
||||||
}
|
}
|
||||||
|
|
||||||
local night_frequent = {
|
local night_frequent = {
|
||||||
handler = {},
|
handler = {},
|
||||||
|
frequency = 25,
|
||||||
{name="Crickets_At_NightCombo", length=69}
|
{name="Crickets_At_NightCombo", length=69}
|
||||||
}
|
}
|
||||||
|
|
||||||
local day = {
|
local day = {
|
||||||
handler = {},
|
handler = {},
|
||||||
|
frequency = 5,
|
||||||
{name="Best Cardinal Bird", length=4},
|
{name="Best Cardinal Bird", length=4},
|
||||||
{name="craw", length=3},
|
{name="craw", length=3},
|
||||||
{name="bluejay", length=18}
|
{name="bluejay", length=18}
|
||||||
@ -20,6 +21,7 @@ local day = {
|
|||||||
|
|
||||||
local day_frequent = {
|
local day_frequent = {
|
||||||
handler = {},
|
handler = {},
|
||||||
|
frequency = 25,
|
||||||
{name="robin2", length=43},
|
{name="robin2", length=43},
|
||||||
{name="birdsongnl", length=72},
|
{name="birdsongnl", length=72},
|
||||||
{name="bird", length=30}
|
{name="bird", length=30}
|
||||||
@ -27,23 +29,91 @@ local day_frequent = {
|
|||||||
|
|
||||||
local cave = {
|
local cave = {
|
||||||
handler = {},
|
handler = {},
|
||||||
|
frequency = 5,
|
||||||
{name="Bats_in_Cave", length=5}
|
{name="Bats_in_Cave", length=5}
|
||||||
}
|
}
|
||||||
|
|
||||||
local cave_frequent = {
|
local cave_frequent = {
|
||||||
handler = {},
|
handler = {},
|
||||||
{name="drippingwater_dripa", length=2},
|
frequency = 100,
|
||||||
{name="drippingwater_dripb", length=2},
|
{name="drippingwater_drip_a", length=2},
|
||||||
{name="drippingwater_dripc", length=2},
|
{name="drippingwater_drip_b", length=2},
|
||||||
|
{name="drippingwater_drip_c", length=2},
|
||||||
{name="Single_Water_Droplet", length=3},
|
{name="Single_Water_Droplet", length=3},
|
||||||
{name="Spooky_Water_Drops", length=7}
|
{name="Spooky_Water_Drops", length=7}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local water = {
|
||||||
|
handler = {},
|
||||||
|
frequency = 0,--dolphins dont fit into small lakes
|
||||||
|
{name="dolphins", length=6},
|
||||||
|
{name="dolphins_screaming", length=16.5}
|
||||||
|
}
|
||||||
|
|
||||||
|
local water_frequent = {
|
||||||
|
handler = {},
|
||||||
|
frequency = 100,
|
||||||
|
on_stop = "drowning_gasp",
|
||||||
|
{name="scuba1bubbles", length=11},
|
||||||
|
{name="scuba1calm", length=10},
|
||||||
|
{name="scuba1calm2", length=8.5},
|
||||||
|
{name="scuba1interestingbubbles", length=11},
|
||||||
|
{name="scuba1tubulentbubbles", length=10.5}
|
||||||
|
}
|
||||||
|
|
||||||
|
local play_music = minetest.setting_getbool("music") or false
|
||||||
|
local music = {
|
||||||
|
handler = {},
|
||||||
|
frequency = 1,
|
||||||
|
{name="mtest", length=4*60+33, gain=0.3}
|
||||||
|
}
|
||||||
|
|
||||||
|
local is_daytime = function()
|
||||||
|
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_ambience = function(player)
|
||||||
|
local pos = player:getpos()
|
||||||
|
pos.y = pos.y+1.5
|
||||||
|
local nodename = minetest.env:get_node(pos).name
|
||||||
|
if string.find(nodename, "default:water") then
|
||||||
|
if music then
|
||||||
|
return {water=water, water_frequent=water_frequent, music=music}
|
||||||
|
else
|
||||||
|
return {water=water, water_frequent=water_frequent}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if player:getpos().y < 0 then
|
||||||
|
if music then
|
||||||
|
return {cave=cave, cave_frequent=cave_frequent, music=music}
|
||||||
|
else
|
||||||
|
return {cave=cave, cave_frequent=cave_frequent}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if is_daytime() then
|
||||||
|
if music then
|
||||||
|
return {day=day, day_frequent=day_frequent, music=music}
|
||||||
|
else
|
||||||
|
return {day=day, day_frequent=day_frequent}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if music then
|
||||||
|
return {night=night, night_frequent=night_frequent, music=music}
|
||||||
|
else
|
||||||
|
return {night=night, night_frequent=night_frequent}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- start playing the sound, set the handler and delete the handler after sound is played
|
-- start playing the sound, set the handler and delete the handler after sound is played
|
||||||
local play_sound = function(player, list, number)
|
local play_sound = function(player, list, number)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
if list.handler[player_name] == nil then
|
if list.handler[player_name] == nil then
|
||||||
local handler = minetest.sound_play(list[number].name, {to_player=player_name})
|
local gain = 1.0
|
||||||
|
if list[number].gain ~= nil then
|
||||||
|
gain = list[number].gain
|
||||||
|
end
|
||||||
|
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
|
||||||
if handler ~= nil then
|
if handler ~= nil then
|
||||||
list.handler[player_name] = handler
|
list.handler[player_name] = handler
|
||||||
minetest.after(list[number].length, function(args)
|
minetest.after(list[number].length, function(args)
|
||||||
@ -64,6 +134,9 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.cave == nil then
|
if still_playing.cave == nil then
|
||||||
local list = cave
|
local list = cave
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -71,6 +144,9 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.cave_frequent == nil then
|
if still_playing.cave_frequent == nil then
|
||||||
local list = cave_frequent
|
local list = cave_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -78,6 +154,9 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.night == nil then
|
if still_playing.night == nil then
|
||||||
local list = night
|
local list = night
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -85,6 +164,9 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.night_frequent == nil then
|
if still_playing.night_frequent == nil then
|
||||||
local list = night_frequent
|
local list = night_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -92,6 +174,9 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.day == nil then
|
if still_playing.day == nil then
|
||||||
local list = day
|
local list = day
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -99,6 +184,39 @@ local stop_sound = function(still_playing, player)
|
|||||||
if still_playing.day_frequent == nil then
|
if still_playing.day_frequent == nil then
|
||||||
local list = day_frequent
|
local list = day_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
|
minetest.sound_stop(list.handler[player_name])
|
||||||
|
list.handler[player_name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if still_playing.music == nil then
|
||||||
|
local list = music
|
||||||
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
|
minetest.sound_stop(list.handler[player_name])
|
||||||
|
list.handler[player_name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if still_playing.water == nil then
|
||||||
|
local list = water
|
||||||
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
|
minetest.sound_stop(list.handler[player_name])
|
||||||
|
list.handler[player_name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if still_playing.water_frequent == nil then
|
||||||
|
local list = water_frequent
|
||||||
|
if list.handler[player_name] ~= nil then
|
||||||
|
if list.on_stop ~= nil then
|
||||||
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
||||||
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
list.handler[player_name] = nil
|
list.handler[player_name] = nil
|
||||||
end
|
end
|
||||||
@ -108,56 +226,17 @@ end
|
|||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer+dtime
|
timer = timer+dtime
|
||||||
if timer < 5 then
|
if timer < 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
timer = 0
|
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
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
if math.random(1, 100) <= 50 then
|
local ambiences = get_ambience(player)
|
||||||
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.8 then
|
stop_sound(ambiences, player)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,ambience in pairs(ambiences) do
|
||||||
if player:getpos().y < 0 then
|
if math.random(1, 100) <= ambience.frequency then
|
||||||
stop_sound({cave=true, cave_frequent=true}, player)
|
play_sound(player, ambience, math.random(1, #ambience))
|
||||||
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
|
||||||
end
|
end
|
||||||
|
@ -44,9 +44,9 @@ local cave_frequent = {
|
|||||||
local is_daytime = function()
|
local is_daytime = function()
|
||||||
local daytime
|
local daytime
|
||||||
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.8 then
|
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.8 then
|
||||||
daytime = true
|
|
||||||
else
|
|
||||||
daytime = false
|
daytime = false
|
||||||
|
else
|
||||||
|
daytime = true
|
||||||
end
|
end
|
||||||
return daytime
|
return daytime
|
||||||
end
|
end
|
||||||
@ -54,31 +54,17 @@ end
|
|||||||
local setting = function (player_parm)
|
local setting = function (player_parm)
|
||||||
local settinglist
|
local settinglist
|
||||||
if player_parm:getpos().y < 0 then
|
if player_parm:getpos().y < 0 then
|
||||||
settinglist = cave
|
settinglist = {cave, cave_frequent}
|
||||||
else
|
else
|
||||||
if is_daytime then
|
if is_daytime then
|
||||||
settinglist = day
|
settinglist = {day, day_frequent}
|
||||||
else
|
else
|
||||||
settinglist = night
|
settinglist = {night, night_frequent}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return settinglist
|
return settinglist
|
||||||
end
|
end
|
||||||
|
|
||||||
local setting_frequent = function (setting_parm)
|
|
||||||
local setting_frequent_list
|
|
||||||
if setting_parm == cave then
|
|
||||||
setting_frequent_list = cave_frequent
|
|
||||||
elseif setting_parm == day then
|
|
||||||
setting_frequent_list = day_frequent
|
|
||||||
else
|
|
||||||
setting_frequent_list = night_frequent
|
|
||||||
end
|
|
||||||
return setting_frequent_list
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- start playing the sound, set the handler and delete the handler after sound is played
|
-- start playing the sound, set the handler and delete the handler after sound is played
|
||||||
local play_sound = function(player, list, number)
|
local play_sound = function(player, list, number)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
@ -152,22 +138,20 @@ minetest.register_globalstep(function(dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
|
|
||||||
-- normal sounds
|
|
||||||
if math.random(1, 100) <= 5 then --this 5 is what I am trying to change based on setting
|
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
|
||||||
player_setting = setting(player)
|
|
||||||
stop_sound({cave=true, cave_frequent=true}, player)--big problem here
|
|
||||||
play_sound(player, player_setting, math.random(1, #player_setting))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- frequent sounds
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
if math.random(1, 100) <= 50 then
|
player_setting = setting(player)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
|
||||||
player_setting_frequent = setting_frequent(player)
|
-- normal sounds
|
||||||
stop_sound({cave=true, cave_frequent=true}, player)--big problem here
|
if math.random(1, 100) <= 5 then --this 5 is what I am trying to change based on setting
|
||||||
play_sound(player, player_setting_frequent, math.random(1, #player_setting_frequent))
|
stop_sound({player_setting}, player)--big problem here
|
||||||
|
play_sound(player, player_setting[1], math.random(1, #player_setting[0]))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- frequent sounds
|
||||||
|
if math.random(1, 100) <= 50 then
|
||||||
|
stop_sound({player_setting}, player)--big problem here
|
||||||
|
play_sound(player, player_setting[2], math.random(1, #player_setting[1]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
)
|
BIN
ambience/sounds/ambiance.ogg
Normal file
BIN
ambience/sounds/ambiance.ogg
Normal file
Binary file not shown.
Binary file not shown.
BIN
ambience/sounds/dark_ambiance.ogg
Normal file
BIN
ambience/sounds/dark_ambiance.ogg
Normal file
Binary file not shown.
BIN
ambience/sounds/drowning_gasp.ogg
Normal file
BIN
ambience/sounds/drowning_gasp.ogg
Normal file
Binary file not shown.
BIN
ambience/sounds/eastern_feeling.ogg
Normal file
BIN
ambience/sounds/eastern_feeling.ogg
Normal file
Binary file not shown.
BIN
ambience/sounds/mtest.ogg
Normal file
BIN
ambience/sounds/mtest.ogg
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user