1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2025-11-02 00:25:33 +01:00

add ambience.group_total() function, tweak & tidy code

This commit is contained in:
tenplus1
2024-12-18 10:34:03 +00:00
parent db65aebead
commit 703f6c4370
4 changed files with 91 additions and 92 deletions

12
api.txt
View File

@@ -43,14 +43,22 @@ ambience.add_set("windy", {
{name = "crow", length = 3, ephemeral = true},
},
sound_check = function(def)
local number = totals["default:sand"] or 0 -- yep, can also be nil
local number = def.totals["default:sand"] or 0 -- yep, can also be nil
if number > 20 then
return "windy", 0.2 -- return set to play and optional gain volume
end
end,
end
})
Counting group: nodes
---------------------
Instead of counting each node total for things like leaves within the sound_check function, you could use the following helper function to return their total instead e.g.
local number = ambience.group_totals(def.totals, "leaves") -- count all group:leaves
Getting Sound Set
-----------------