Startup
Starts the library and tells you when it is ready.
The server compiles the SOUNDS Configuration into the schema once. Every client receives that schema when it
joins. Until a side has started, most of the library errors when used, so other scripts should wait with
WaitForSchema or ConnectForSchema.
Functions
InitServer
This item only works when running on the server. ServerCompiles the SOUNDS Configuration into the schema, publishes it to clients, and destroys the Configuration.
DANGER
Call this once. The schema is locked after it is built, so sounds and SoundGroups cannot be added while the game runs.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local VluxySF = require(ReplicatedStorage.Packages.VluxySF)
VluxySF.Startup.InitServer(ServerStorage.SOUNDS)
InitClient
This item only works when running on the client. ClientThis is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsStartup.InitClient(timeout: number?--
How long to wait for the preloads, in seconds. Default is 5. 0 does not wait.
) → ()Receives the schema from the server, then builds and preloads every sound tagged for preloading.
The schema is ready as soon as it is received, so WaitForSchema and ConnectForSchema in other scripts resume
then. This call itself yields until the preloads finish or timeout seconds pass, whichever comes first, and
warns if it timed out. Pass 0 to not wait at all: the preloads still run in the background, no warning is
printed, and you can check on them with IsPreloaded or WaitForPreload.
DANGER
Call this once per client.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VluxySF = require(ReplicatedStorage.Packages.VluxySF)
VluxySF.Startup.InitClient(4)
IsInitialized
Startup.IsInitialized() → boolean--
Whether the schema is ready on this side.
print(VluxySF.Startup.IsInitialized())
WaitForSchema
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsStartup.WaitForSchema() → ()Yields until the schema is ready. Returns right away if it already is.
VluxySF.Startup.WaitForSchema()
VluxySF.FetchPlayOnce("MySound")
ConnectForSchema
Startup.ConnectForSchema(finished: () → ()--
Runs when the schema is ready.
) → () → ()--
Cancels the callback if it has not run yet.
Runs the callback once the schema is ready, without yielding. If it already is, the callback runs in a new thread right away.
VluxySF.Startup.ConnectForSchema(function()
VluxySF.FetchPlayOnce("MySound")
end)
-- This line does not wait.
IsPreloaded
This item only works when running on the client. ClientStartup.IsPreloaded() → boolean--
Whether the sounds tagged for preloading have finished loading.
print(VluxySF.Startup.IsPreloaded())
WaitForPreload
This item only works when running on the client. ClientThis is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsStartup.WaitForPreload() → ()
Yields until the sounds tagged for preloading have finished loading. Returns right away if they have.
Useful after InitClient(0).
VluxySF.Startup.InitClient(0)
-- Do other startup work here.
VluxySF.Startup.WaitForPreload()