forked from mtcontrib/ambience
.30 adjust sound and music volume ingame
This commit is contained in:
parent
ca404b2395
commit
9dd2417898
BIN
ambience.zip
BIN
ambience.zip
Binary file not shown.
@ -1,12 +1,12 @@
|
|||||||
--------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------
|
||||||
--Ambiance Configuration for version .29
|
--Ambience Configuration for version .30
|
||||||
--working on Flying
|
--added music volume /mvol 0-3.3 music gain gets multiplied by this.
|
||||||
--PROB: wind stops short even though it says we are still flying and don't hear the start sound.
|
--added sound volume /mvol 0-1 sound gain gets multiplied by this.
|
||||||
--really BIG prob, it ruins water meaning you hear beach while treading water. (find out if still hear it in .28) because
|
--Working on:
|
||||||
--it is fairly rare in .29
|
--find out why wind stops while flying
|
||||||
--need a separate onstart variable for flying?
|
--add an extra node near feet to handle treading water as a special case, and don't have to use node under feet. which gets
|
||||||
--removing unneeded stuff.
|
--invoked when staning on a ledge near water.
|
||||||
|
--reduce redundant code (stopplay and add ambience to list)
|
||||||
|
|
||||||
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
|
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
|
||||||
|
|
||||||
@ -36,11 +36,20 @@ local desert_frequent_frequency = 700 --desertwind
|
|||||||
local desert_frequent_volume = 1.0
|
local desert_frequent_volume = 1.0
|
||||||
local swimming_frequent_frequency = 1000 --swimming splashes
|
local swimming_frequent_frequency = 1000 --swimming splashes
|
||||||
local swimming_frequent_volume = 1.0
|
local swimming_frequent_volume = 1.0
|
||||||
|
local water_surface_volume = 1.0 -- sloshing water
|
||||||
|
local lava_volume = 1.0 --lava
|
||||||
|
local flowing_water_volume = .4 --waterfall
|
||||||
|
local splashing_water_volume = 1
|
||||||
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
|
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
|
||||||
local music_volume = 0.3
|
local music_volume = 0.3
|
||||||
|
|
||||||
--End of Config
|
--End of Config
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
|
local ambiences
|
||||||
local counter=0--*****************
|
local counter=0--*****************
|
||||||
|
local SOUNDVOLUME = 1
|
||||||
|
local MUSICVOLUME = 1
|
||||||
|
local sound_vol = 1
|
||||||
local last_x_pos = 0
|
local last_x_pos = 0
|
||||||
local last_y_pos = 0
|
local last_y_pos = 0
|
||||||
local last_z_pos = 0
|
local last_z_pos = 0
|
||||||
@ -48,9 +57,11 @@ local node_under_feet
|
|||||||
local node_at_upper_body
|
local node_at_upper_body
|
||||||
local node_at_lower_body
|
local node_at_lower_body
|
||||||
local node_3_under_feet
|
local node_3_under_feet
|
||||||
|
|
||||||
local played_on_start = false
|
local played_on_start = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local night = {
|
local night = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = night_frequency,
|
frequency = night_frequency,
|
||||||
@ -144,8 +155,8 @@ local flying = {
|
|||||||
local water = {
|
local water = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 0,--dolphins dont fit into small lakes
|
frequency = 0,--dolphins dont fit into small lakes
|
||||||
{name="dolphins", length=6},
|
{name="dolphins", length=6, gain=1},
|
||||||
{name="dolphins_screaming", length=16.5}
|
{name="dolphins_screaming", length=16.5, gain=1}
|
||||||
}
|
}
|
||||||
|
|
||||||
local water_frequent = {
|
local water_frequent = {
|
||||||
@ -154,7 +165,7 @@ local water_frequent = {
|
|||||||
on_stop = "drowning_gasp",
|
on_stop = "drowning_gasp",
|
||||||
--on_start = "Splash",
|
--on_start = "Splash",
|
||||||
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
|
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
|
||||||
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
|
{name="scuba1calm", length=10, gain=water_frequent_volume}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
|
||||||
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
|
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
|
||||||
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
|
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
|
||||||
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
|
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
|
||||||
@ -165,35 +176,35 @@ local water_surface = {
|
|||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
on_stop = "Splash",
|
on_stop = "Splash",
|
||||||
on_start = "Splash",
|
on_start = "Splash",
|
||||||
{name="lake_waves_2_calm", length=9.5},
|
{name="lake_waves_2_calm", length=9.5, gain=water_surface_volume},
|
||||||
{name="lake_waves_2_variety", length=13.1}
|
{name="lake_waves_2_variety", length=13.1, gain=water_surface_volume}
|
||||||
}
|
}
|
||||||
local splashing_water = {
|
local splashing_water = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
{name="Splash", length=1.22, gain=1}
|
{name="Splash", length=1.22, gain=splashing_water_volume}
|
||||||
}
|
}
|
||||||
|
|
||||||
local flowing_water = {
|
local flowing_water = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
{name="small_waterfall", length=14, gain=.4}
|
{name="small_waterfall", length=14, gain=flowing_water_volume}
|
||||||
}
|
}
|
||||||
local flowing_water2 = {
|
local flowing_water2 = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
{name="small_waterfall", length=11, gain=.3}
|
{name="small_waterfall", length=11, gain=flowing_water_volume}
|
||||||
}
|
}
|
||||||
|
|
||||||
local lava = {
|
local lava = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
{name="earth01a", length=20}
|
{name="earth01a", length=20, gain=lava_volume}
|
||||||
}
|
}
|
||||||
local lava2 = {
|
local lava2 = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = 1000,
|
frequency = 1000,
|
||||||
{name="earth01a", length=15}
|
{name="earth01a", length=15, gain=lava_volume}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -201,6 +212,7 @@ local play_music = minetest.setting_getbool("music") or false
|
|||||||
local music = {
|
local music = {
|
||||||
handler = {},
|
handler = {},
|
||||||
frequency = music_frequency,
|
frequency = music_frequency,
|
||||||
|
is_music=true,
|
||||||
{name="mtest", length=4*60+33, gain=music_volume},
|
{name="mtest", length=4*60+33, gain=music_volume},
|
||||||
{name="echos", length=2*60+26, gain=music_volume},
|
{name="echos", length=2*60+26, gain=music_volume},
|
||||||
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
|
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
|
||||||
@ -455,12 +467,18 @@ local get_ambience = function(player)
|
|||||||
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, is_music)
|
||||||
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 gain = 1.0
|
local gain = 1.0
|
||||||
if list[number].gain ~= nil then
|
if list[number].gain ~= nil then
|
||||||
gain = list[number].gain
|
if is_music then
|
||||||
|
gain = list[number].gain*MUSICVOLUME
|
||||||
|
--minetest.chat_send_all("gain music: " .. gain )
|
||||||
|
else
|
||||||
|
gain = list[number].gain*SOUNDVOLUME
|
||||||
|
--minetest.chat_send_all("gain sound: " .. gain )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
|
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
|
||||||
if handler ~= nil then
|
if handler ~= nil then
|
||||||
@ -484,7 +502,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -494,7 +512,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -504,7 +522,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = swimming_frequent
|
local list = swimming_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -514,7 +532,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = beach
|
local list = beach
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -524,7 +542,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = beach_frequent
|
local list = beach_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -534,7 +552,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = desert
|
local list = desert
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -544,7 +562,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = desert_frequent
|
local list = desert_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -554,7 +572,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -564,7 +582,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -574,7 +592,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -584,7 +602,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
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
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -594,7 +612,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = music
|
local list = music
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -604,7 +622,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = flowing_water
|
local list = flowing_water
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -614,7 +632,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = flowing_water2
|
local list = flowing_water2
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -624,7 +642,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = lava
|
local list = lava
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -634,7 +652,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = lava2
|
local list = lava2
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -644,7 +662,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = water
|
local list = water
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -654,7 +672,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = water_surface
|
local list = water_surface
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
played_on_start = false
|
played_on_start = false
|
||||||
end
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
@ -665,7 +683,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = water_frequent
|
local list = water_frequent
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
-- minetest.chat_send_all("list.on_stop " .. list.on_stop )
|
-- minetest.chat_send_all("list.on_stop " .. list.on_stop )
|
||||||
played_on_start = false
|
played_on_start = false
|
||||||
end
|
end
|
||||||
@ -680,7 +698,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
-- minetest.chat_send_all("handler flying " )
|
-- minetest.chat_send_all("handler flying " )
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
-- minetest.chat_send_all("onstop flying" )
|
-- minetest.chat_send_all("onstop flying" )
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
played_on_start = false
|
played_on_start = false
|
||||||
end
|
end
|
||||||
minetest.sound_stop(list.handler[player_name])
|
minetest.sound_stop(list.handler[player_name])
|
||||||
@ -691,7 +709,7 @@ local stop_sound = function(still_playing, player)
|
|||||||
local list = splashing_water
|
local list = splashing_water
|
||||||
if list.handler[player_name] ~= nil then
|
if list.handler[player_name] ~= nil then
|
||||||
if list.on_stop ~= nil then
|
if list.on_stop ~= nil then
|
||||||
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
|
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
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
|
||||||
@ -709,7 +727,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
timer = 0
|
timer = 0
|
||||||
|
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
local ambiences = get_ambience(player)
|
ambiences = get_ambience(player)
|
||||||
stop_sound(ambiences, player)
|
stop_sound(ambiences, player)
|
||||||
for _,ambience in pairs(ambiences) do
|
for _,ambience in pairs(ambiences) do
|
||||||
if math.random(1, 1000) <= ambience.frequency then
|
if math.random(1, 1000) <= ambience.frequency then
|
||||||
@ -720,15 +738,42 @@ minetest.register_globalstep(function(dtime)
|
|||||||
-- end
|
-- end
|
||||||
if ambience.on_start ~= nil and played_on_start == false then
|
if ambience.on_start ~= nil and played_on_start == false then
|
||||||
played_on_start = true
|
played_on_start = true
|
||||||
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
|
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
|
||||||
end
|
end
|
||||||
-- minetest.chat_send_all("ambience: " ..ambience )
|
-- minetest.chat_send_all("ambience: " ..ambience )
|
||||||
-- if ambience.on_start ~= nil and played_on_start_flying == false then
|
-- if ambience.on_start ~= nil and played_on_start_flying == false then
|
||||||
-- played_on_start_flying = true
|
-- played_on_start_flying = true
|
||||||
-- minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
|
-- minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
|
||||||
-- end
|
-- end
|
||||||
play_sound(player, ambience, math.random(1, #ambience))
|
local is_music =false
|
||||||
|
if ambience.is_music ~= nil then
|
||||||
|
is_music = true
|
||||||
|
end
|
||||||
|
play_sound(player, ambience, math.random(1, #ambience),is_music)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_chatcommand("svol", {
|
||||||
|
params = "<svol>",
|
||||||
|
description = "set volume of sounds, default 1 normal volume.",
|
||||||
|
privs = {server=true},
|
||||||
|
func = function(name, param)
|
||||||
|
SOUNDVOLUME = param
|
||||||
|
-- local player = minetest.env:get_player_by_name(name)
|
||||||
|
-- ambiences = get_ambience(player)
|
||||||
|
-- stop_sound({}, player)
|
||||||
|
minetest.chat_send_player(name, "Sound volume set.")
|
||||||
|
end, })
|
||||||
|
minetest.register_chatcommand("mvol", {
|
||||||
|
params = "<mvol>",
|
||||||
|
description = "set volume of music, default 1 normal volume.",
|
||||||
|
privs = {server=true},
|
||||||
|
func = function(name, param)
|
||||||
|
MUSICVOLUME = param
|
||||||
|
-- local player = minetest.env:get_player_by_name(name)
|
||||||
|
-- stop_sound({}, player)
|
||||||
|
-- ambiences = get_ambience(player)
|
||||||
|
minetest.chat_send_player(name, "Music volume set.")
|
||||||
|
end, })
|
Loading…
Reference in New Issue
Block a user