Search docs
Search modules and symbols
Modules

Docs / API / Modules / unsafe

Engine calls (unsafe)

Platform

@s2script/sdk/unsafe

Call or detour an engine function the framework does not wrap, declared in your own gamedata. Validated at load and degraded to null on failure — requires a manifest permission (engine:calls or engine:hooks) and an operator allow-list entry.

Import

import { EngineCalls } from "@s2script/sdk/unsafe";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

Generated from the shipped type definitions.

interface
EngineCalls

The calls this plugin declares. The base interface is EMPTY — s2s build generates .s2script/gamedata.d.ts, which augments this from your gamedata's calls section.

interface
EngineHooks

The inbound hooks this plugin declares. The base interface is EMPTY — s2s build generates .s2script/hooks.d.ts, which augments this from your gamedata's hooks section.

const
Engine

Plugin-declared engine calls and inbound hooks, resolved from this plugin's own gamedata.

import { Engine } from "@s2script/sdk/unsafe";
// Resolve ONCE at load — null means the descriptor failed a load-time gate.
const ignite = Engine.call("ignite");
if (!ignite) console.log(`unavailable: ${Engine.status("ignite")}`);
const onFoo = Engine.hook("onFoo");
if (onFoo) onFoo((view) => { view.reason = 0; });
call(name: K): EngineCalls[K] | null
The declared call, or null when its descriptor failed a load-time gate (signature miss, validator rejection, slot outside .text, missing platform entry, or the plugin is not operator-allow-listed). Guard once at load; the returned function is a plain callable.
status(name: string): string
Why a call descriptor is unavailable; "available" when it resolved. For diagnostics/operator reports.
hook(name: K): EngineHooks[K] | null
The declared hook's subscribe function, or null when its descriptor failed a load-time gate (same class of reasons as Engine.call, plus a missing validate or an unknown thunk shape). Guard once at load; the returned function records the handler and lazily installs the detour. The owner is always the calling plugin — you cannot subscribe to another plugin's hook through this factory (game-package hooks hang off ctx.*).
hookStatus(name: string): string
Why a hook descriptor is unavailable; "available" when it resolved.
Back to modules All packages

s2script — Source 2 plugin framework

GitHub