Vanguard API Reference¶
This page lists every public field and method on the main Vanguard module. Concept guides provide deeper examples and behavioral explanation.
Public main-module methods accept both dot and colon syntax:
Utility object methods use normal colon syntax unless documented otherwise.
Public Fields¶
| Field | Runtime | Description |
|---|---|---|
Name |
Both | "Vanguard" |
Version |
Both | Installed framework version, currently 0.1.15 |
NetworkProtocol |
Both | Network compatibility version, currently 2 |
Player |
Client | Players.LocalPlayer |
Util |
Both | Folder containing all utility ModuleScripts |
Error |
Both | Linked error-code utility; alias of Vanguard.Util.Error |
Logger |
Both | Root framework logger |
Math |
Both | Number helper utility; alias of Vanguard.Util.Math |
Switch |
Both | Case-dispatch utility; alias of Vanguard.Util.Switch |
Services |
Server | Service registry |
Controllers |
Client | Controller registry |
Components |
Both | Component registry |
Classes |
Both | Class registry |
Plugins |
Both | Plugin registry for the current runtime |
Configuration and Startup¶
Configure¶
Merges options and returns the selected configuration. Must be called before Start.
GetConfig¶
Returns a shallow clone of selected options.
Start¶
Starts the current runtime. Resolves after init hooks, start-hook scheduling, component startup, and readiness. Rejects when called more than once or when init fails.
Bootstrap¶
Accepted forms:
or:
Vanguard.Bootstrap({
Services = servicesFolder,
Controllers = controllersFolder,
Components = componentsFolder,
Classes = classesFolder,
Plugins = pluginsFolder,
Options = options,
})
Server uses Services; client uses Controllers. Plugins load first, then
classes, then services/controllers, then components.
OnStart¶
Resolves immediately when startup completed or waits for completion.
IsStarted¶
Returns whether startup completed.
Logging and Helpers¶
CreateLogger¶
Creates a logger using the current configured LogLevel. Default scope is Vanguard.
CreateCache¶
Shortcut for Vanguard.Util.Cache.new(options).
CreateRateLimiter¶
Shortcut for Vanguard.Util.RateLimiter.new(options).
Plugin API¶
CreatePlugin¶
Validates and registers a plugin before startup.
RegisterPlugin¶
Registers a plugin table. Re-registering the same plugin is idempotent.
AddPlugins¶
Loads direct plugin ModuleScript children before startup.
AddPluginsDeep¶
Loads descendant plugin ModuleScripts before startup.
LoadPlugins and LoadPluginsDeep are aliases.
GetPlugin¶
Returns a registered plugin or throws VG-REG-002.
HasPlugin¶
Checks whether a plugin exists in the current runtime registry.
GetPlugins¶
Returns a shallow clone of the plugin registry.
UnregisterPlugin¶
Removes a plugin before startup and returns it when present.
Error¶
Vanguard.Error.format(code: string, message: string?, cause: any?): string
Vanguard.Error.raise(code: string, message: string?, cause: any?, level: number?)
Formats or throws errors with stable codes and direct documentation links. See the Error Reference.
Math¶
Vanguard.Math.map(value, inMin, inMax, outMin, outMax, clampResult?)
Vanguard.Math.moveTowards(current, target, maxDelta)
Provides interpolation, range mapping, easing, wrapping, snapping, comparison, and averaging helpers. See Math.
Switch¶
Vanguard.Switch.new(value):Case(expected, result):Default(result):Run(...)
Vanguard.Switch.match(value, cases, defaultResult?, ...)
Provides ordered builder dispatch and concise direct-map dispatch without fall-through. See Switch.
Update Check¶
CheckForUpdates¶
Server only. Starts the asynchronous configured Wally index check. The normal server startup calls this automatically after readiness when enabled.
Network Information¶
GetNetworkInfo¶
Returns Protocol and ServerVersion. Client fields populate when the remote container is resolved.
GetNetworkStats¶
Server only. Returns cloned accepted/rejected totals, counts by code, and counts by Service.Remote.
ResetNetworkStats¶
Server only. Clears all counters.
Service API¶
CreateService¶
Server only. Validates and registers a service before startup. Creates an empty Client table and scoped logger when omitted.
AddServices¶
Loads direct ModuleScript children before startup.
AddServicesDeep¶
Loads all descendant ModuleScripts before startup.
LoadServices and LoadServicesDeep are aliases.
GetService¶
Server: returns a registered service after startup begins.
Client: returns or builds a remote service proxy after startup begins.
GetServices¶
Returns the server service registry after startup begins.
Controller API¶
CreateController¶
Client only. Validates and registers a controller before startup and creates its logger when omitted.
AddControllers¶
Loads direct ModuleScript children before startup.
AddControllersDeep¶
Loads all descendant ModuleScripts before startup.
LoadControllers and LoadControllersDeep are aliases.
GetController¶
Returns a registered client controller. Unknown lookup errors with registered names.
GetControllers¶
Returns the controller registry after startup begins.
Component API¶
CreateComponent¶
Creates or registers a component. Components created after startup start immediately when StartComponents is enabled.
AddComponents¶
Loads direct ModuleScript children.
AddComponentsDeep¶
Loads descendant ModuleScripts.
LoadComponents and LoadComponentsDeep are aliases.
GetComponent¶
Returns the named component or errors.
GetComponents¶
Returns the component registry.
Class API¶
CreateClass¶
Creates and registers a class. A string Extends field resolves an
already-registered parent. Definitions may group instance API in Public,
per-instance hidden state in Private, and class-only API in Static.
RegisterClass¶
Registers a class created by Vanguard.Util.Class.
AddClasses¶
Loads direct class ModuleScript children.
AddClassesDeep¶
Loads descendant class ModuleScripts.
LoadClasses and LoadClassesDeep are aliases.
GetClass¶
Returns the registered class or errors.
HasClass¶
Checks registry membership by name.
GetClasses¶
Returns a shallow clone of the class registry.
UnregisterClass¶
Removes and returns the registry entry. Existing instances are unaffected.
Remote Definition API¶
CreateSignal¶
Server definition marker for a reliable bidirectional remote signal.
CreateUnreliableSignal¶
Server definition marker for an unreliable signal with reliable fallback.
CreateProperty¶
Server definition marker for a server-owned replicated property.
CreateReplicator¶
Server definition marker for a server-owned replicated state tree. Requires
network protocol 2. See Replicators.
Module Loading Behavior¶
Every Add* method:
- validates the parent is an Instance;
- collects matching ModuleScripts;
- sorts by full name;
- requires each module inside
pcall; - registers the returned definition inside
pcall; - logs and skips failures;
- returns successful values.
One bad module does not stop the remaining modules from loading.