API ReferenceGE Extensionsui
UI Audio
Plays UI sound effects from a JSON-defined sound class registry.
Plays UI sound effects from a JSON-defined sound class registry.
Overview
ui_audio loads sound class definitions from ui/soundClasses.json on first update, then provides a simple function to play named UI sounds.
Extension path: lua/ge/extensions/ui/audio.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
playEventSound | (className, eventName) | Plays a one-shot UI sound effect by class and event name. |
onFirstUpdate | () | Loads ui/soundClasses.json into the internal sound classes table. |
Internals
Sound Classes JSON
The JSON file maps class names to event names to SFX paths:
{
"button": {
"click": { "sfx": "event:>UI>Button>Click" },
"hover": { "sfx": "event:>UI>Button>Hover" }
},
"notification": {
"popup": { "sfx": "event:>UI>Notification>Popup" }
}
}Playing Sounds
local function playEventSound(className, eventName)
local sound_class = M.ui_sound_classes[className] or {}
local event = sound_class[eventName]
if event then
Engine.Audio.playOnce('AudioGui', event.sfx)
end
endSounds play on the 'AudioGui' audio source group.
How It Works
- On first update,
ui/soundClasses.jsonis loaded into memory - UI code calls
ui_audio.playEventSound("button", "click")to play sounds - The SFX path is looked up and played as a one-shot via
Engine.Audio.playOnce - Invalid class/event combinations silently do nothing
Additional Exports
The following exports are available but not yet documented in detail:
M.onFirstUpdateM.playEventSound