Skip to content

Towards moddable audio - #984

Merged
ajhalme merged 5 commits into
C7-Game:Developmentfrom
ajhalme:audio
Sep 3, 2026
Merged

Towards moddable audio#984
ajhalme merged 5 commits into
C7-Game:Developmentfrom
ajhalme:audio

Conversation

@ajhalme

@ajhalme ajhalme commented Aug 27, 2026

Copy link
Copy Markdown
Contributor
  • Replicate TextureLoader pattern for audio
  • Lua config for reference based audio file targeting
  • audio.lua files for initial Lua-based modding/override
  • General audio refactor

-> C7-Game/Assets#15

@ajhalme
ajhalme marked this pull request as ready for review August 29, 2026 23:54
@ajhalme

ajhalme commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Basic lua-moddable audio ready for review. Keeping it very simple to start with.

Comment thread C7/Audio/AudioLoader.cs Outdated
Comment thread C7/Audio/AudioLoader.cs
Comment thread C7/Audio/AudioLoader.cs
Comment on lines +99 to +105
foreach (string part in parts) {
if (current is Table table && table[part] != null) {
current = table[part];
} else {
return null;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, this will end up returning the last such table entry, correct? We would iterate backwards and return the first match in that case. But why would multiple substrings be found in the table anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to TextureLoader. Inlined it here because it's a compact static helper.

I'm not sure I follow your interpretation. This function resolves the value from a nested Lua structure:

audio.menu = {
  main_menu_1 = "/my/path/file.mp3"
}
Parts:       "menu.main_menu_1" --> ["menu", "main_menu_1"]
init:        current := audio
1st pass:    current["menu"] --> current := {  main_menu_1 = "/my/path/file.mp3" }
2nd pass:    current["main_menu_1"] --> current := "/my/path/file.mp3"
return:      "/my/path/file.mp3"

The modding Lua code makes a second lookup to see if there's a direct key-based override for the structured key, using it as a flat key-value lookup. That is, there is no structure to parse in the modded code. We could make the moddable stuff structured as well, but there's no need for now.

The reason to have structured Lua data in the first place is to enable not just simple values but full objects with properties to be retrieved by a single key.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I missed that this is recursing into the table structure

@ajhalme
ajhalme merged commit 4260913 into C7-Game:Development Sep 3, 2026
3 checks passed
@ajhalme
ajhalme deleted the audio branch September 3, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants