Prefabs
Prefabs are reusable arrangements of one or more configured tiles. Where a template is a complete GM screen loaded as a new session, a prefab is a smaller building block: GMs add it to any screen of any session from the canvas right-click menu, and the tiles appear at the point they clicked. A prefab might be a paired map and initiative tracker, a set of prepared note tiles, or a grouped reference block.
Creating a prefab
You can create a prefab by creating a definition in the plugin manifest.json file.
Example:
{
// [...]
"prefabs": [
{ "$ref": "prefabs/my-prefab/manifest.json" }
]
}You can also scaffold one with the CLI by selecting Prefab during npx @overseer-studio/sdk init.
Prefab definition
A prefab is defined by a manifest.json file containing an id, a label, and the tiles it inserts:
{
"$schema": "https://overseer.studio/schemas/prefab/manifest.json",
"id": "@scope/my-plugin-battle-pair",
"label": "Battle pair",
"tiles": [
{
"id": "tile-1",
"type": "@overseer/text",
"name": "Notes",
"config": { "value": "Session notes" },
"x": 0,
"y": 0,
"width": 480,
"height": 270
}
]
}A few things to know about the tiles payload:
- Positions are relative. Tile
x/yare offsets from the prefab’s own top-left corner. The app places the whole arrangement at the point the GM clicked. - Ids are regenerated. Tile ids only need to be unique within the prefab; every use stamps fresh ids, so the same prefab can be added many times.
- Group tiles work. A tile with
type: "group"andconfig.childTileIdsreferencing other tiles in the payload is inserted with its children and tabs intact. - Assets can be bundled. A tile config value may be a
{ "$ref": "assets/map.png" }pointing at a file inside the prefab folder; it resolves to the bundled file when the prefab is used. See Bundled files.
Bundled files
A $ref in a tile’s config points at a file in your plugin. The path is relative to the prefab’s manifest.json.
A $ref can sit at any depth in a config value: directly on a field, or inside a list or an object that the extension reads.
{
"id": "tile-1",
"type": "@scope/my-plugin-gallery",
"config": {
"cover": { "$ref": "assets/cover.webp" },
"items": [
{ "name": "Harbor", "image": { "$ref": "assets/harbor.webp" } },
{ "name": "Lighthouse", "image": { "$ref": "assets/lighthouse.webp" } }
]
},
"x": 0,
"y": 0,
"width": 480,
"height": 360
}Each prefab resolves its own files. Two prefabs in one plugin can each have a file called assets/cover.webp.
A $ref cannot replace the whole config object. Put it under a config field name, as in the example. npx @overseer-studio/sdk build stops with an error when a $ref sits at the root of config, or when a referenced file is missing.
The same rules apply to the tiles in a template.
Reference
Please reference https://overseer.studio/schemas/prefab/manifest.json for a complete definition of the file.