1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2024-12-26 18:50:29 +01:00

add biome name to sound_check, add additional sounds with pitch change

This commit is contained in:
tenplus1 2024-07-11 14:31:00 +01:00
parent f3f2cedd4b
commit c1a076ec8c
4 changed files with 24 additions and 5 deletions

View File

@ -21,5 +21,6 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
- 1.6 - Finding env_sounds disables water and lava sets, added 'ambience_water_move' flag to override water walking sounds, use eye level for head node. - 1.6 - Finding env_sounds disables water and lava sets, added 'ambience_water_move' flag to override water walking sounds, use eye level for head node.
- 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game. - 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game.
- 1.8 - Players can set induvidual volume for sound and music which is saved. - 1.8 - Players can set induvidual volume for sound and music which is saved.
- 1.9 - Tidy code, refactor music playing, add biome name to sound_check.
Code license: MIT Code license: MIT

View File

@ -27,6 +27,7 @@ ambience.add_set(set_name, def)
'positions' position data for every node found 'positions' position data for every node found
'head_node' name of node at player head level 'head_node' name of node at player head level
'feet_node' nameof node at player foot level 'feet_node' nameof node at player foot level
'biome' name of biome at current position
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. If ephemeral is true then no handler will be used and sound will be played in background alongside other sounds. 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.

View File

@ -166,6 +166,10 @@ local get_ambience = function(player, tod, name)
if set and set.sound_check then if set and set.sound_check then
-- get biome data
local bdata = minetest.get_biome_data(pos)
local biome = bdata and minetest.get_biome_name(bdata.biome) or ""
-- pass settings to function for condition check -- pass settings to function for condition check
local set_name, gain = set.sound_check({ local set_name, gain = set.sound_check({
player = player, player = player,
@ -174,7 +178,8 @@ local get_ambience = function(player, tod, name)
totals = cn, totals = cn,
positions = ps, positions = ps,
head_node = nod_head, head_node = nod_head,
feet_node = nod_feet feet_node = nod_feet,
biome = biome
}) })
-- if conditions met return set name and gain value -- if conditions met return set name and gain value

View File

@ -212,6 +212,7 @@ ambience.add_set("beach", {
sounds = { sounds = {
{name = "seagull", length = 4.5, ephemeral = true}, {name = "seagull", length = 4.5, ephemeral = true},
{name = "seagull", length = 4.5, pitch = 1.2, ephemeral = true},
{name = "beach", length = 13}, {name = "beach", length = 13},
{name = "gull", length = 1, ephemeral = true}, {name = "gull", length = 1, ephemeral = true},
{name = "beach_2", length = 6} {name = "beach_2", length = 6}
@ -287,6 +288,8 @@ ambience.add_set("cave", {
sounds = { sounds = {
{name = "drippingwater1", length = 1.5, ephemeral = true}, {name = "drippingwater1", length = 1.5, ephemeral = true},
{name = "drippingwater2", length = 1.5, ephemeral = true}, {name = "drippingwater2", length = 1.5, ephemeral = true},
{name = "drippingwater2", length = 1.5, pitch = 1.2, ephemeral = true},
{name = "drippingwater2", length = 1.5, pitch = 1.4, ephemeral = true},
{name = "bats", length = 5, ephemeral = true} {name = "bats", length = 5, ephemeral = true}
}, },
@ -311,7 +314,8 @@ ambience.add_set("jungle", {
{name = "deer", length = 7, ephemeral = true}, {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, ephemeral = true} {name = "peacock", length = 2, ephemeral = true},
{name = "peacock", length = 2, pitch = 1.2, ephemeral = true}
}, },
nodes = {"default:jungletree"}, nodes = {"default:jungletree"},
@ -336,7 +340,8 @@ ambience.add_set("jungle_night", {
{name = "jungle_night_1", length = 4, ephemeral = true}, {name = "jungle_night_1", length = 4, ephemeral = true},
{name = "jungle_night_2", length = 4, ephemeral = true}, {name = "jungle_night_2", length = 4, ephemeral = true},
{name = "deer", length = 7, ephemeral = true}, {name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1, ephemeral = true} {name = "frog", length = 1, ephemeral = true},
{name = "frog", length = 1, pitch = 1.3, ephemeral = true}
}, },
sound_check = function(def) sound_check = function(def)
@ -361,10 +366,13 @@ ambience.add_set("day", {
{name = "craw", length = 3, ephemeral = true}, {name = "craw", length = 3, ephemeral = true},
{name = "bluejay", length = 6, ephemeral = true}, {name = "bluejay", length = 6, ephemeral = true},
{name = "robin", length = 4, ephemeral = true}, {name = "robin", length = 4, ephemeral = true},
{name = "robin", length = 4, pitch = 1.2, ephemeral = true},
{name = "bird1", length = 11}, {name = "bird1", length = 11},
{name = "bird2", length = 6, ephemeral = true}, {name = "bird2", length = 6, ephemeral = true},
{name = "crestedlark", length = 6, ephemeral = true}, {name = "crestedlark", length = 6, ephemeral = true},
{name = "crestedlark", length = 6, pitch = 1.1, ephemeral = true},
{name = "peacock", length = 2, ephemeral = true}, {name = "peacock", length = 2, ephemeral = true},
{name = "peacock", length = 2, pitch = 1.2, ephemeral = true},
{name = "wind", length = 9} {name = "wind", length = 9}
}, },
@ -394,10 +402,12 @@ ambience.add_set("night", {
sounds = { sounds = {
{name = "hornedowl", length = 2, ephemeral = true}, {name = "hornedowl", length = 2, ephemeral = true},
{name = "hornedowl", length = 2, pitch = 1.1, ephemeral = true},
{name = "wolves", length = 4, gain = 0.4, ephemeral = true}, {name = "wolves", length = 4, gain = 0.4, ephemeral = true},
{name = "cricket", length = 6, ephemeral = true}, {name = "cricket", length = 6, ephemeral = true},
{name = "deer", length = 7, ephemeral = true}, {name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1, ephemeral = true} {name = "frog", length = 1, ephemeral = true},
{name = "frog", length = 1, pitch = 1.2, ephemeral = true}
}, },
sound_check = function(def) sound_check = function(def)
@ -424,7 +434,9 @@ ambience.add_set("high_up", {
sounds = { sounds = {
{name = "desertwind", length = 8}, {name = "desertwind", length = 8},
{name = "wind", length = 9} {name = "desertwind", length = 8, pitch = 1.3},
{name = "wind", length = 9},
{name = "wind", length = 9, pitch = 1.4}
}, },
nodes = {"default:snowblock"}, nodes = {"default:snowblock"},