Skip to content

api.campaign.configuration()

The campaign's configuration — every setting the system module and the platform declare, resolved to its value or its default.

Part of the Action API · Function reference · Since Action API 0.4 (v0.102.0)

Signature

api.campaign.configuration(): Promise<Record<string, unknown>>
api.campaign.configuration(key: string): Promise<unknown>

Asynchronous — await it.

Parameters

Parameter Type Description
key string One setting's key. Optional: without it, the whole record.

Returns

Without a key, an object of every setting the campaign's schema declares — the system module's (startingLevel, abilityScoreMethods, advancement, encumbrance…) and the platform's dotted keys (players.makeMaps, treasure.mode…) — each at its edited value or, where the GM never touched it, its default. With a key, that one value; undefined for a key the schema does not declare.

The record is fetched once per run, so reading several keys costs one request, and the object handed back is a copy: writing to it changes nothing.

Example

const level = await api.campaign.configuration('startingLevel');
const methods = await api.campaign.configuration('abilityScoreMethods');
sendMessage(`New characters start at level ${level}; scores by ${methods.join(' or ')}.`);

Read-only, and needs a map in a campaign

The settings are the GM's, edited on the campaign's Configuration sections; an action reads them and cannot write them. The campaign is the one the map the action runs on belongs to, so the call throws with a plain sentence when there is no open map, or the map is in no campaign.