Schema
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 {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
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.