Generated from the shipped type definitions.
Game-event subscriptions on this plugin's load-scope (PluginContext.events).
Handlers fire for clients that connect AFTER Active. To cover already-connected clients, seed
explicitly in the factory: for (const c of Clients.all()) { … } — there is no framework
replay (replaying onConnect for pre-existing clients would fire auth/ban/reservation logic
out of its real order).
Entity lifecycle + damage subscriptions on this plugin's load-scope (PluginContext.entities).
Per-frame + map/precache hooks on this plugin's load-scope (PluginContext.server).
Console/chat command registration on this plugin's load-scope (PluginContext.commands).
Config live-reload subscription on this plugin's load-scope (PluginContext.config).
A producer-backed inter-plugin interface: its methods, plus forward subscriptions.
A disposable bundle of subscriptions (PluginContext.createScope). Registering through a scope
lets you drop the whole group at once with Scope.clear without unloading the plugin.
The load-scoped context passed to a plugin's PluginFactory. Its sub-objects register every
subscription; all registration is load-window only (buffered, armed at Active).
— This plugin's id (manifest id). readonly previous: unknown
— The revived hot-reload handoff (the previous instance's state() return), or undefined.readonly events: CtxEvents
— Game-event subscriptions (CtxEvents).readonly clients: CtxClients
— Client-lifecycle subscriptions (CtxClients).readonly entities: CtxEntities
— Entity/damage subscriptions (CtxEntities).readonly server: CtxServer
— Per-frame/map/precache subscriptions (CtxServer).readonly commands: CtxCommands
— Console/chat command registration (CtxCommands).readonly config: CtxConfig
— Config live-reload subscription (CtxConfig).publish(name: string, impl: T): PublishHandle
— Publish this plugin's manifest-declared interface. Buffered; goes live at Active.use(name: string): InterfaceHandle<T>
— Resolve a HARD dep (must be in pluginDependencies). Immediate — the proxy is callable inside the factory.tryUse(name: string): InterfaceHandle<T> | null
— Resolve an OPTIONAL dep (must be in optionalPluginDependencies); null while unpublished. — Allocate a disposable subscription scope (load-window only — the capability originates at load). Optional lifecycle hooks a PluginFactory may return to participate in unload + hot-reload.
A plugin's body: called once at load with the PluginContext, optionally returning
PluginHooks. May be async (the load waits for it to settle).
The opaque artifact plugin returns; a module must export default it to be a valid plugin.
fn plugin(factory: PluginFactory): PluginDefinition
Define a plugin from its factory. export default the result — the host calls the factory once at load.
import { plugin } from "@s2script/sdk/plugin";
// examples/greeter-plugin/src/plugin.ts:8
export default plugin((ctx) => {
const handle = ctx.publish("@demo/greeter", impl);
ctx.server.onGameFrame(() => handle.emit("greeted", { slot: 0 }));
});