From c1a076ec8c5e378b64174087b2adc928457712e9 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 11 Jul 2024 14:31:00 +0100 Subject: [PATCH] add biome name to sound_check, add additional sounds with pitch change --- README.md | 1 + api.txt | 1 + init.lua | 7 ++++++- soundsets.lua | 20 ++++++++++++++++---- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3e7cf9..3fba36c 100644 --- a/README.md +++ b/README.md @@ -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.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.9 - Tidy code, refactor music playing, add biome name to sound_check. Code license: MIT diff --git a/api.txt b/api.txt index 013f5de..3233a02 100644 --- a/api.txt +++ b/api.txt @@ -27,6 +27,7 @@ ambience.add_set(set_name, def) 'positions' position data for every node found 'head_node' name of node at player head 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 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. diff --git a/init.lua b/init.lua index 920f1db..1fb8748 100644 --- a/init.lua +++ b/init.lua @@ -166,6 +166,10 @@ local get_ambience = function(player, tod, name) 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 local set_name, gain = set.sound_check({ player = player, @@ -174,7 +178,8 @@ local get_ambience = function(player, tod, name) totals = cn, positions = ps, head_node = nod_head, - feet_node = nod_feet + feet_node = nod_feet, + biome = biome }) -- if conditions met return set name and gain value diff --git a/soundsets.lua b/soundsets.lua index a9bc549..c95a4e4 100644 --- a/soundsets.lua +++ b/soundsets.lua @@ -212,6 +212,7 @@ ambience.add_set("beach", { sounds = { {name = "seagull", length = 4.5, ephemeral = true}, + {name = "seagull", length = 4.5, pitch = 1.2, ephemeral = true}, {name = "beach", length = 13}, {name = "gull", length = 1, ephemeral = true}, {name = "beach_2", length = 6} @@ -287,6 +288,8 @@ ambience.add_set("cave", { sounds = { {name = "drippingwater1", 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} }, @@ -311,7 +314,8 @@ ambience.add_set("jungle", { {name = "deer", length = 7, ephemeral = true}, {name = "canadianloon2", length = 14}, {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"}, @@ -336,7 +340,8 @@ ambience.add_set("jungle_night", { {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} + {name = "frog", length = 1, ephemeral = true}, + {name = "frog", length = 1, pitch = 1.3, ephemeral = true} }, sound_check = function(def) @@ -361,10 +366,13 @@ ambience.add_set("day", { {name = "craw", length = 3, ephemeral = true}, {name = "bluejay", length = 6, ephemeral = true}, {name = "robin", length = 4, ephemeral = true}, + {name = "robin", length = 4, pitch = 1.2, ephemeral = true}, {name = "bird1", length = 11}, {name = "bird2", 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, pitch = 1.2, ephemeral = true}, {name = "wind", length = 9} }, @@ -394,10 +402,12 @@ ambience.add_set("night", { sounds = { {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 = "cricket", length = 6, 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) @@ -424,7 +434,9 @@ ambience.add_set("high_up", { sounds = { {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"},