1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2024-12-24 01:30:30 +01:00

added underwater sound

This commit is contained in:
tenplus1 2015-01-14 14:50:19 +00:00
parent de029527a6
commit a10f69d5e3
2 changed files with 29 additions and 5 deletions

View File

@ -1,7 +1,7 @@
--= Ambience lite by TenPlus1 (11 Sep 2014)
--= Ambience lite by TenPlus1 (14th Jan 2015)
local max_frequency_all = 1000 -- larger number means less frequent sounds (100-2000)
local max_frequency_all = 1000 -- larger number means more frequent sounds (100-2000)
local SOUNDVOLUME = 1
local volume = 0.3
local ambiences
@ -56,6 +56,11 @@ local flowing_water = {
{name="waterfall", length=6}
}
local underwater = {
handler = {}, frequency = 1000,
{name="scuba", length=8}
}
local splash = {
handler = {}, frequency = 1000,
{name="swim_splashing", length=3},
@ -110,9 +115,17 @@ local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y + 0.2
pos.y = pos.y + 1.4 -- head level
if minetest.get_node(pos).name == "default:water_source" then
if minetest.get_node(pos).name == "default:water_source"
or minetest.get_node(pos).name == "default:water_flowing" then
return {underwater=underwater}
end
pos.y = pos.y - 1.2 -- feet level
if minetest.get_node(pos).name == "default:water_source"
or minetest.get_node(pos).name == "default:water_flowing" then
return {splash=splash}
end
@ -134,7 +147,7 @@ local get_ambience = function(player)
return {desert=desert}
end
if player:getpos().y < 5 then
if player:getpos().y < -10 then
return {cave=cave}
end
@ -254,6 +267,17 @@ local stop_sound = function(still_playing, player)
end
end
if not still_playing.underwater then
local list = underwater
if list.handler[player_name] then
if list.on_stop then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if not still_playing.lava then
local list = lava
if list.handler[player_name] then

BIN
sounds/scuba.ogg Normal file

Binary file not shown.