Skip to main content

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. Server
Startup.InitServer(
soundFolder: Configuration--

The SOUNDS Configuration.

) → ()

Compiles 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. Yields
Startup.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. Yields
Startup.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. Client
Startup.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. Yields
Startup.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()
Show raw api
{
    "functions": [
        {
            "name": "InitServer",
            "desc": "Compiles the `SOUNDS` Configuration into the schema, publishes it to clients, and destroys the Configuration.\n\n:::danger\nCall this once. The schema is locked after it is built, so sounds and SoundGroups cannot be added while the game\nruns.\n:::\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal ServerStorage = game:GetService(\"ServerStorage\")\n\nlocal VluxySF = require(ReplicatedStorage.Packages.VluxySF)\n\nVluxySF.Startup.InitServer(ServerStorage.SOUNDS)\n```",
            "params": [
                {
                    "name": "soundFolder",
                    "desc": "The `SOUNDS` Configuration.",
                    "lua_type": "Configuration"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 94,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "InitClient",
            "desc": "Receives the schema from the server, then builds and preloads every sound tagged for preloading.\n\nThe schema is ready as soon as it is received, so `WaitForSchema` and `ConnectForSchema` in other scripts resume\nthen. This call itself yields until the preloads finish or `timeout` seconds pass, whichever comes first, and\nwarns if it timed out. Pass `0` to not wait at all: the preloads still run in the background, no warning is\nprinted, and you can check on them with `IsPreloaded` or `WaitForPreload`.\n\n:::danger\nCall this once per client.\n:::\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nlocal VluxySF = require(ReplicatedStorage.Packages.VluxySF)\n\nVluxySF.Startup.InitClient(4)\n```",
            "params": [
                {
                    "name": "timeout",
                    "desc": "How long to wait for the preloads, in seconds. Default is 5. `0` does not wait.",
                    "lua_type": "number?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Client"
            ],
            "yields": true,
            "source": {
                "line": 157,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "IsInitialized",
            "desc": "```lua\nprint(VluxySF.Startup.IsInitialized())\n```",
            "params": [],
            "returns": [
                {
                    "desc": "Whether the schema is ready on this side.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 217,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "WaitForSchema",
            "desc": "Yields until the schema is ready. Returns right away if it already is.\n\n```lua\nVluxySF.Startup.WaitForSchema()\n\nVluxySF.FetchPlayOnce(\"MySound\")\n```",
            "params": [],
            "returns": [],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 234,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "ConnectForSchema",
            "desc": "Runs the callback once the schema is ready, without yielding. If it already is, the callback runs in a new thread\nright away.\n\n```lua\nVluxySF.Startup.ConnectForSchema(function()\n\tVluxySF.FetchPlayOnce(\"MySound\")\nend)\n\n-- This line does not wait.\n```",
            "params": [
                {
                    "name": "finished",
                    "desc": "Runs when the schema is ready.",
                    "lua_type": "() -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "Cancels the callback if it has not run yet.",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 260,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "IsPreloaded",
            "desc": "```lua\nprint(VluxySF.Startup.IsPreloaded())\n```",
            "params": [],
            "returns": [
                {
                    "desc": "Whether the sounds tagged for preloading have finished loading.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "realm": [
                "Client"
            ],
            "source": {
                "line": 285,
                "path": "lib/Api/Startup.luau"
            }
        },
        {
            "name": "WaitForPreload",
            "desc": "Yields until the sounds tagged for preloading have finished loading. Returns right away if they have.\nUseful after `InitClient(0)`.\n\n```lua\nVluxySF.Startup.InitClient(0)\n\n-- Do other startup work here.\n\nVluxySF.Startup.WaitForPreload()\n```",
            "params": [],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Client"
            ],
            "yields": true,
            "source": {
                "line": 307,
                "path": "lib/Api/Startup.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Startup",
    "desc": "Starts the library and tells you when it is ready.\n\nThe server compiles the `SOUNDS` Configuration into the schema once. Every client receives that schema when it\njoins. Until a side has started, most of the library errors when used, so other scripts should wait with\n`WaitForSchema` or `ConnectForSchema`.",
    "source": {
        "line": 26,
        "path": "lib/Api/Startup.luau"
    }
}