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

added ephemeral flag for sounds

This commit is contained in:
tenplus1 2020-06-14 15:01:59 +01:00
parent e5457003cd
commit d5ff07abe0
4 changed files with 27 additions and 26 deletions

View File

@ -17,6 +17,6 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
- 1.2 - Added PlayerPlus compatibility, removed fire sounds, added volume changes - 1.2 - Added PlayerPlus compatibility, removed fire sounds, added volume changes
- 1.3 - Added API for use with other mods, code rewrite - 1.3 - Added API for use with other mods, code rewrite
- 1.4 - Re-ordered water sets to come before fire and lava, day/night sounds play when leaves around and above ground - 1.4 - Re-ordered water sets to come before fire and lava, day/night sounds play when leaves around and above ground
- 1.5 - Added 'flame_sound' and fire redo check, code tidy - 1.5 - Added 'flame_sound' and fire redo check, code tidy and tweak, added ephemeral flag for background sounds.
Code license: MIT Code license: MIT

View File

@ -29,7 +29,7 @@ ambience.add_set(set_name, def)
'feet_node' nameof node at player foot level 'feet_node' nameof node at player foot level
This will let you add a set or sounds with the frequency it's used and check This will let you add a set or sounds with the frequency it's used and check
function for it to play. function for it to play. If ephemeral is true then no handler will be used and sound will be played in background alongside other sounds.
e.g. e.g.
@ -39,6 +39,7 @@ ambience.add_set("windy", {
sounds = { sounds = {
{name = "wind", length = 9, gain = 0.3}, {name = "wind", length = 9, gain = 0.3},
{name = "desertwind", length = 8, gain = 0.3}, {name = "desertwind", length = 8, gain = 0.3},
{name = "crow", length = 3, ephemeral = true},
}, },
sound_check = function(def) sound_check = function(def)
local number = totals["default:sand"] or 0 -- yep, can also be nil local number = totals["default:sand"] or 0 -- yep, can also be nil

View File

@ -244,7 +244,7 @@ minetest.register_globalstep(function(dtime)
handler = minetest.sound_play(ambience.name, { handler = minetest.sound_play(ambience.name, {
to_player = player_name, to_player = player_name,
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * SOUNDVOLUME gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * SOUNDVOLUME
}) }, ambience.ephemeral)
-- only continue if sound is playing -- only continue if sound is playing
if handler then if handler then

View File

@ -203,9 +203,9 @@ ambience.add_set("beach", {
frequency = 40, frequency = 40,
sounds = { sounds = {
{name = "seagull", length = 4.5}, {name = "seagull", length = 4.5, ephemeral = true},
{name = "beach", length = 13}, {name = "beach", length = 13},
{name = "gull", length = 1}, {name = "gull", length = 1, ephemeral = true},
{name = "beach_2", length = 6} {name = "beach_2", length = 6}
}, },
@ -252,7 +252,7 @@ ambience.add_set("desert", {
frequency = 20, frequency = 20,
sounds = { sounds = {
{name = "coyote", length = 2.5}, {name = "coyote", length = 2.5, ephemeral = true},
{name = "wind", length = 9}, {name = "wind", length = 9},
{name = "desertwind", length = 8} {name = "desertwind", length = 8}
}, },
@ -277,8 +277,8 @@ ambience.add_set("cave", {
frequency = 60, frequency = 60,
sounds = { sounds = {
{name = "drippingwater1", length = 1.5}, {name = "drippingwater1", length = 1.5, ephemeral = true},
{name = "drippingwater2", length = 1.5} {name = "drippingwater2", length = 1.5, ephemeral = true}
}, },
sound_check = function(def) sound_check = function(def)
@ -297,10 +297,10 @@ ambience.add_set("jungle", {
sounds = { sounds = {
{name = "jungle_day_1", length = 7}, {name = "jungle_day_1", length = 7},
{name = "deer", length = 7}, {name = "deer", length = 7, ephemeral = true},
{name = "canadianloon2", length = 14}, {name = "canadianloon2", length = 14},
{name = "bird1", length = 11}, {name = "bird1", length = 11},
{name = "peacock", length = 2} {name = "peacock", length = 2, ephemeral = true}
}, },
nodes = {"default:jungletree"}, nodes = {"default:jungletree"},
@ -322,10 +322,10 @@ ambience.add_set("jungle_night", {
frequency = 200, frequency = 200,
sounds = { sounds = {
{name = "jungle_night_1", length = 4}, {name = "jungle_night_1", length = 4, ephemeral = true},
{name = "jungle_night_2", length = 4}, {name = "jungle_night_2", length = 4, ephemeral = true},
{name = "deer", length = 7}, {name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1} {name = "frog", length = 1, ephemeral = true}
}, },
sound_check = function(def) sound_check = function(def)
@ -346,14 +346,14 @@ ambience.add_set("day", {
frequency = 40, frequency = 40,
sounds = { sounds = {
{name = "cardinal", length = 3}, {name = "cardinal", length = 3, ephemeral = true},
{name = "craw", length = 3}, {name = "craw", length = 3, ephemeral = true},
{name = "bluejay", length = 6}, {name = "bluejay", length = 6, ephemeral = true},
{name = "robin", length = 4}, {name = "robin", length = 4, ephemeral = true},
{name = "bird1", length = 11}, {name = "bird1", length = 11},
{name = "bird2", length = 6}, {name = "bird2", length = 6, ephemeral = true},
{name = "crestedlark", length = 6}, {name = "crestedlark", length = 6, ephemeral = true},
{name = "peacock", length = 2}, {name = "peacock", length = 2, ephemeral = true},
{name = "wind", length = 9} {name = "wind", length = 9}
}, },
@ -382,11 +382,11 @@ ambience.add_set("night", {
frequency = 40, frequency = 40,
sounds = { sounds = {
{name = "hornedowl", length = 2}, {name = "hornedowl", length = 2, ephemeral = true},
{name = "wolves", length = 4, gain = 0.4}, {name = "wolves", length = 4, gain = 0.4, ephemeral = true},
{name = "cricket", length = 6}, {name = "cricket", length = 6, ephemeral = true},
{name = "deer", length = 7}, {name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1} {name = "frog", length = 1, ephemeral = true}
}, },
sound_check = function(def) sound_check = function(def)