1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2024-12-23 17:20: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.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.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

View File

@ -29,7 +29,7 @@ ambience.add_set(set_name, def)
'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
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.
@ -39,6 +39,7 @@ ambience.add_set("windy", {
sounds = {
{name = "wind", length = 9, gain = 0.3},
{name = "desertwind", length = 8, gain = 0.3},
{name = "crow", length = 3, ephemeral = true},
},
sound_check = function(def)
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, {
to_player = player_name,
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * SOUNDVOLUME
})
}, ambience.ephemeral)
-- only continue if sound is playing
if handler then

View File

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