Authoring plugins

Authoring plugins

Plugins are ordinary npm packages with a s2script block in package.json, built to a .s2sp archive.

Scaffold

npx @s2script/cli create my-plugin
cd my-plugin
npx s2script build

Drop the resulting .s2sp into addons/s2script/plugins/. The runtime watches that directory: drop → load, replace → hot-reload, delete → unload.

package.json contract

{
  "name": "@demo/hello",
  "version": "0.1.0",
  "main": "src/plugin.ts",
  "s2script": {
    "apiVersion": "1.x",
    "pluginDependencies": {
      "@s2script/frame": "^1.0.0",
      "@s2script/cs2": "^1.0.0"
    },
    "config": {
      "greeting": { "type": "string", "default": "hello" }
    }
  }
}
  • dependencies — npm build deps only
  • s2script.pluginDependencies — inter-plugin / capability imports
  • s2script.publishes — interfaces you expose to other plugins
  • s2script.config — typed config materialized at load

Typecheck gate

s2script build typechecks strictly against the shipped @s2script/* .d.ts files and refuses to emit a .s2sp on any error. A failing reload leaves the running plugin untouched.

Imports

import { OnGameFrame } from '@s2script/frame';
import { Player } from '@s2script/cs2';
import { Chat } from '@s2script/chat';

Engine-generic capabilities live in packages like @s2script/entity, /commands, /events. CS2-specific APIs live in @s2script/cs2.

Lifecycle & config

  • Plugin lifecycleonLoad / onUnload handoff and map changes
  • Config — typed defaults, override files, live reload

See the API overview, package reference, and plugin catalog.

s2script — Source 2 plugin framework

GitHub