Skip to main content

Schema

RequiresSchema

Reads the schema: the definitions the library builds sounds from.

Definitions are decoded out of the compiled schema the first time they are asked for. GetDefinition decodes one. Get and GetDefinitions decode every remaining one and then freeze the definitions table.

Called before the library has started, every function here warns once and returns an empty result.

CAUTION

With a large schema, Get and GetDefinitions cost time and keep every definition in memory. Use them for tooling and debugging, not on hot paths; use GetDefinition or Has for one sound.

Types​

SoundSchema​

interface SoundSchema {
SoundGroupContainer: SoundGroup--

Main SoundGroup for all other SoundGroups.

SoundGroups: SoundGroups--

Dictionary of SoundGroups under the Main SoundGroup.

UnattachedSounds: Configuration--

Configuration for Un-Parented Sounds.

WarmedSounds: Configuration--

Configuration for Warmed Sounds.

PreloadedSounds: Configuration--

Configuration for Preloaded Sounds.

SoundDefinitions: SoundDefinitions--

Dictionary of SoundDefinitions.

PreloadNames: {string}--

Names of the sounds the client preloads on startup.

}

The Schema for the library that is shared on client and server.

Functions​

Get​

Schema.Get() → SoundSchema?--

The frozen schema, or nil before the library has started.

Returns the full schema. Decodes every definition that has not been decoded yet.

local schema = VluxySF.Schema.Get()

if schema then
	print(schema.PreloadNames)
end

GetDefinitions​

Schema.GetDefinitions() → SoundDefinitions--

The frozen definitions. Empty before the library has started.

Returns every definition, keyed by sound name. Decodes every definition that has not been decoded yet.

for name, definition in VluxySF.Schema.GetDefinitions() do
	print(name, definition.EffectsCount)
end

GetDefinition​

Schema.GetDefinition(
name: string--

The sound name.

) → SoundDefinition?--

The frozen definition, or nil.

Returns one definition, decoding it the first time. Prints nothing for a name that is not in the schema; use Has to check first if that matters.

local definition = VluxySF.Schema.GetDefinition("MySound")

if definition then
	print(definition.Properties.SoundId)
end

Has​

Schema.Has(
name: string--

The sound name.

) → boolean--

Whether a sound has that name. false before the library has started.

Checks whether a sound is in the schema, without decoding it and without a warning.

if VluxySF.Schema.Has(`VO_{npcName}`) then
	VluxySF.OneShot(`VO_{npcName}`)
end

GetNames​

Schema.GetNames() → {string}--

A new array of every sound name, in the order they were compiled. Empty before the library

print(VluxySF.Schema.GetNames())

has started.

Show raw api
{
    "functions": [
        {
            "name": "Get",
            "desc": "Returns the full schema. Decodes every definition that has not been decoded yet.\n\n```lua\nlocal schema = VluxySF.Schema.Get()\n\nif schema then\n\tprint(schema.PreloadNames)\nend\n```",
            "params": [],
            "returns": [
                {
                    "desc": "The frozen schema, or `nil` before the library has started.",
                    "lua_type": "SoundSchema?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 43,
                "path": "lib/Api/Schema.luau"
            }
        },
        {
            "name": "GetDefinitions",
            "desc": "Returns every definition, keyed by sound name. Decodes every definition that has not been decoded yet.\n\n```lua\nfor name, definition in VluxySF.Schema.GetDefinitions() do\n\tprint(name, definition.EffectsCount)\nend\n```",
            "params": [],
            "returns": [
                {
                    "desc": "The frozen definitions. Empty before the library has started.",
                    "lua_type": "SoundDefinitions"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 66,
                "path": "lib/Api/Schema.luau"
            }
        },
        {
            "name": "GetDefinition",
            "desc": "Returns one definition, decoding it the first time. Prints nothing for a name that is not in the schema; use `Has`\nto check first if that matters.\n\n```lua\nlocal definition = VluxySF.Schema.GetDefinition(\"MySound\")\n\nif definition then\n\tprint(definition.Properties.SoundId)\nend\n```",
            "params": [
                {
                    "name": "name",
                    "desc": "The sound name.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The frozen definition, or `nil`.",
                    "lua_type": "SoundDefinition?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "lib/Api/Schema.luau"
            }
        },
        {
            "name": "Has",
            "desc": "Checks whether a sound is in the schema, without decoding it and without a warning.\n\n```lua\nif VluxySF.Schema.Has(`VO_{npcName}`) then\n\tVluxySF.OneShot(`VO_{npcName}`)\nend\n```",
            "params": [
                {
                    "name": "name",
                    "desc": "The sound name.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "Whether a sound has that name. `false` before the library has started.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 115,
                "path": "lib/Api/Schema.luau"
            }
        },
        {
            "name": "GetNames",
            "desc": "```lua\nprint(VluxySF.Schema.GetNames())\n```\n\nhas started.",
            "params": [],
            "returns": [
                {
                    "desc": "A new array of every sound name, in the order they were compiled. Empty before the library",
                    "lua_type": "{ string }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 135,
                "path": "lib/Api/Schema.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "SoundSchema",
            "desc": "The `Schema` for the library that is shared on client and server.",
            "fields": [
                {
                    "name": "SoundGroupContainer",
                    "lua_type": "SoundGroup",
                    "desc": "Main `SoundGroup` for all other `SoundGroups`."
                },
                {
                    "name": "SoundGroups",
                    "lua_type": "SoundGroups",
                    "desc": "Dictionary of `SoundGroups` under the Main `SoundGroup`."
                },
                {
                    "name": "UnattachedSounds",
                    "lua_type": "Configuration",
                    "desc": "`Configuration` for Un-Parented `Sounds`."
                },
                {
                    "name": "WarmedSounds",
                    "lua_type": "Configuration",
                    "desc": "`Configuration` for `Warmed` `Sounds`."
                },
                {
                    "name": "PreloadedSounds",
                    "lua_type": "Configuration",
                    "desc": "`Configuration` for `Preloaded` `Sounds`."
                },
                {
                    "name": "SoundDefinitions",
                    "lua_type": "SoundDefinitions",
                    "desc": "Dictionary of `SoundDefinitions`."
                },
                {
                    "name": "PreloadNames",
                    "lua_type": "{ string }",
                    "desc": "Names of the sounds the client preloads on startup."
                }
            ],
            "source": {
                "line": 25,
                "path": "lib/Types.luau"
            }
        }
    ],
    "name": "Schema",
    "desc": "Reads the schema: the definitions the library builds sounds from.\n\nDefinitions are decoded out of the compiled schema the first time they are asked for. `GetDefinition` decodes one.\n`Get` and `GetDefinitions` decode every remaining one and then freeze the definitions table.\n\nCalled before the library has started, every function here warns once and returns an empty result.\n\n:::caution\nWith a large schema, `Get` and `GetDefinitions` cost time and keep every definition in memory. Use them for\ntooling and debugging, not on hot paths; use `GetDefinition` or `Has` for one sound.\n:::",
    "tags": [
        "RequiresSchema"
    ],
    "source": {
        "line": 24,
        "path": "lib/Api/Schema.luau"
    }
}