Dynamic Music Track
Music track that reacts to game facts
A dynamic music track plays a base music loop and optionally activates additional layers based on a readable fact entry.
Champs
| Champ | Type | Par défaut | Description |
|---|---|---|---|
baseTrack | Var<Sound> | EMPTY | Base music track that always plays when active |
sfxLayer | Var<Sound>? | — | Optional sfx layer that activates when the trigger fact is met |
melodyLayer | Var<Sound>? | — | Optional melody layer that activates when the trigger fact is met |
triggerFact | Ref<ReadableFactEntry> | — | The readable fact entry to check (e.g., a danger_level fact) |
activationThreshold | Int | 1 | Fact value threshold to activate additional layers |
checkInterval | Duration | ofSeconds(5) | How often to check the fact value (in seconds) |
layer | AudioLayer | MUSIC | Audio layer for music. All three sounds go through the mixer on this layer, so they follow the player's volume for it.Valeurs :MASTERMUSICAMBIENTSFXVOICE |
Champs TypeWriter communs (criteria, modifiers, triggers)
| Champ | Type | Par défaut | Description |
|---|---|---|---|
criteria | List<Criteria> | empty | — |
modifiers | List<Modifier> | empty | — |
triggers | List<Ref<TriggerableEntry>> | empty | — |
How to use it
When the action runs, baseTrack starts once. Every checkInterval, the extension reads triggerFact for the player: when the value reaches activationThreshold, sfxLayer and melodyLayer start; when it falls back below, they are stopped. The check continues until the player leaves. All three sounds play through the mixer on layer, so they follow the player's volume for it (a layer set to 0 means silence).
The base track is not repeated by the extension: use a sound long enough, or one that loops in your resource pack.