Skip to content

DataTransform

A declarative recipe for enriching an entity’s JSON context before it is rendered.

Transforms are loaded by SystemManager from the JSON files in a game system’s views/transforms directory, keyed by file name, and looked up per entity type (falling back to the parent entity type) via SystemManager.transform(for:).

When an entity builds its view context it applies the matching transform in three steps: referenced objects are resolved and inlined, global modifiers are collected from the listed key paths, and finally the dynamic attribute groups are evaluated with those modifiers applied. This is what turns raw stored attributes into the computed values (derived scores, formatted text, rolled formulas) that templates and native views read.

View JSON Schema

Property Type Required Description
debug boolean No Enables verbose logging while the transform is evaluated.
attributes Object No Ordered groups of dynamic attributes to compute. Each group is a JSON object whose keys are destination key paths and whose values are either Stencil template strings — a rendered result prefixed with # is evaluated as a formula — or configuration objects describing a query and its operations. An optional modifiers array in a group lists attribute key paths (a r/ prefix marks a regular expression); matching modifiers are applied to the context before the group is computed and are then consumed, so later groups no longer see them. Groups are processed in order, so a group may build on values computed by earlier ones.
references Array<string> No Key paths whose reference values are resolved from Realm and inlined into the context. Applied before attributes are computed, so dynamic attributes can read the resolved objects.
modifiers Array<string> No Key paths from which global modifiers are extracted into the entity’s active modifier list. Only modifiers that are enabled and have global scope are collected; they are merged with the entity’s own active modifiers before attributes are computed.