Modules

Docs / API / Modules / config

Config

Platform

@s2script/sdk/config

typed access to the plugin's materialized config.

Import

import { ConfigValue } from "@s2script/sdk/config";

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.

type
ConfigValue

A materialized config value: a scalar, or a nested section object of further values.

type
Config

The whole materialized config: top-level keys to ConfigValues. Passed to ctx.config.onChange.

const
config

Typed access to this plugin's materialized config values (declared under s2script.config in the manifest).

import { config } from "@s2script/sdk/config";
// plugins/antiflood/src/plugin.ts:31 — re-read on live-reload
const maxTokens = config.getInt("max_tokens");
getString(key: string): string
A config value as a string. "" if the key is absent.
getInt(key: string): number
A config value as an integer. 0 if the key is absent or non-numeric.
getFloat(key: string): number
A config value as a float. 0 if the key is absent or non-numeric.
getBool(key: string): boolean
A config value as a boolean. false if the key is absent.
readFile(name: string): string | null
Read a raw file from the configs dir (name includes its extension, e.g. "maplist.txt"). null if absent.
writeFile(name: string, content: string): void
Write a raw file to the configs dir (creates/overwrites).
Back to modules All packages

s2script — Source 2 plugin framework

GitHub