Session Zero Format (.szf) Specification
Overview
The Session Zero Format (.szf) is a structured, human-readable data format for defining and storing tabletop RPG data, including characters, templates, and game assets. It is designed to be simple to write by hand, easy to parse, and flexible enough to support a wide variety of game systems.
Core Principles
- Human-Readable: The format uses plain text and a clear, indented structure that is easy to read and edit.
- Structured & Typed: Data is organized into logical sections with explicitly declared field types defined in templates.
- Extensible: The format can be extended with new fields and sections without breaking existing parsers.
- Portable: .szf files are self-contained and can be easily shared and used across different platforms.
File Structure
Every .szf file consists of three main parts: a Header, a Metadata Section, and one or more Content Sections.
Header
The header is mandatory and must be the first two lines of the file. It declares the file type and the schema version.
!type: [file_type]
!schema: [schema_version]
- !type: Defines the purpose of the file. Valid types are:
- dataset: A collection of related game elements (e.g., items, spells).
- character_template: A blueprint defining the structure of a character sheet.
- character: An instance of a character created from a template.
- session: Data related to a specific game session (future use).
- !schema: The version of the .szf specification the file adheres to (e.g., 1.1.0).
Sections
Data is organized into named sections. Sections create a hierarchical structure for organizing related fields.
Syntax: [SectionName]
SectionName must be a single word, is case-sensitive, and must use PascalCase (e.g., AbilityScores, CharacterInfo).
Nested Sections
Sections can be nested to create a logical hierarchy. The dot (.) notation is used to define a parent-child relationship.
Syntax: [ParentSection.ChildSection]
[AbilityScores]
Strength (number) = 10
[AbilityScores.Modifiers]
StrengthMod (calculated) = (AbilityScores.Strength - 10) / 2
Fields
Fields represent individual pieces of data within a section. Each field has a name, a type, and a value.
Syntax: FieldName (type) = value
- FieldName: The name of the field. Must be a single word, is case-sensitive, and must use PascalCase.
- (type): The data type of the field, enclosed in parentheses.
- =: The assignment operator.
- value: The data assigned to the field.
Comments
Comments are denoted by a hash symbol (#) at the beginning of a line. Parsers should ignore comments.
# This is a full-line comment.
FieldName (text) = Some Value
Field Types
The .szf format supports a variety of field types to handle different kinds of data:
Type | Description | Example Value |
---|---|---|
text | A single line of text. | Elara the Brave |
text-field | A multi-line block of text. | A long sword forged by...\nIt glows faintly. |
number | An integer or floating-point number. | 16 or 3.5 |
bool | A boolean value. | true or false |
calculated | A value derived from a formula. | (Strength - 10) / 2 |
system | A special field that controls application behavior. | |
entry-reference | A reference to a single entry from a dataset. | ClassData or ItemData.Longsword |
entry-reference-list | A comma-separated list of references to entries from a dataset. | CoreFeats.PowerAttack, CoreFeats.Cleave |
File Type Specifications
Dataset (!type: dataset)
A dataset file is a collection of structured entries.
Structure:
- [Metadata] Section: Contains information about the dataset.
- Name (text): The human-readable name of the dataset.
- Type (text): The category of the dataset (e.g., items, spells, classes).
- Guid (text): A globally unique identifier. Optional.
- Version (text): The semantic version of the dataset.
- [EntryName] Section: Each entry represents a specific item, spell, or other game element.
Example: CoreItems.szf
!type: dataset
!schema: 1.1.0
[Metadata]
Name (text) = Core Fantasy Items
Type (text) = items
Guid (text) = c3d4e5f6-g7h8-9012-cdef-123456789012
Version (text) = 1.0.0
Author (text) = Fantasy Creator
Description (text-field) = A collection of basic items for any fantasy campaign.
[Longsword]
Name (text) = Longsword
Description (text-field) = A standard sword with a long blade and crossguard.
Category (text) = Weapon
[Longsword.Stats]
Damage (text) = 1d8 slashing
Weight (number) = 3
Cost (number) = 15
IsMartial (bool) = true
Character Template (!type: character_template)
A character_template defines the structure, fields, and rules for a character sheet.
Structure:
- [Metadata] Section: Contains information about the template.
- [RequiredDatasets] Section: Lists all datasets required by this template.
- [SectionName]: Defines sections on the character sheet with fields, types, and default values.
- System Fields: Special fields that modify section behavior.
Example: FantasyTemplate.szf
!type: character_template
!schema: 1.1.0
[Metadata]
Name (text) = Standard Fantasy Character
Guid (text) = f9e8d7c6-b5a4-3210-9876-543210fedcba
Version (text) = 2.1.0
Author (text) = Template Master
[RequiredDatasets]
ClassData (text) = Core Classes|aaa-bbb-ccc|1.5.0
ItemData (text) = Core Fantasy Items|c3d4e5f6-g7h8-9012-cdef-123456789012|1.0.0
WeaponData (text) = Core Weapons|12345678-90ab-cdef-1234567890ab|1.0.0
[Info]
CharacterName (text) =
Class (entry-reference) = ClassData
[AbilityScores]
Strength (number) = 10
Dexterity (number) = 10
[AbilityScores.Modifiers]
StrengthMod (calculated) = (AbilityScores.Strength - 10) / 2
DexterityMod (calculated) = (AbilityScores.Dexterity - 10) / 2
[Equipment]
DatasetReference (system) = WeaponData
[Inventory]
DatasetType (system) = items
AllowQuantity (system) = true
Character (!type: character)
A character file is an instance of a character_template filled with specific data. It only contains values, as the structure and types are defined by the template.
Example: Elara.szf
!type: character
!schema: 1.1.0
[Metadata]
Name = Aela the Huntress
Guid = a1b2c3d4-e5f6-7890-abcd-ef1234567890
Version = 1.0.0
TemplateRef = Standard Fantasy Character|f9e8d7c6-b5a4-3210-9876-543210fedcba|2.1.0
[Info]
CharacterName = Aela the Huntress
Class = Ranger
[AbilityScores]
Strength = 16
Dexterity = 14
[Equipment]
PrimaryWeapon = ItemData.Longsword
PrimaryWeapon.Quantity = 1
[Inventory]
HealingPotion = ItemData.HealingPotion
HealingPotion.Quantity = 5
HempRope = ItemData.HempRope
HempRope.Quantity = 2
Advanced Features
System Properties
System properties are special fields within a character_template that modify the behavior of a section:
DatasetType (system) = type
: Restricts a section to holding references from datasets of a specific type.DatasetReference (system) = alias
: Restricts a section to holding references from a specific dataset.AllowQuantity (system) = true
: Allows entry-reference fields to have associated quantity fields.
Quantity Fields
If a template section has AllowQuantity (system) = true
, a character file can specify quantities using:
Syntax: ReferenceFieldName.Quantity = value
Calculated Fields
Fields of type calculated
contain formulas that are evaluated by the application. They support:
- Basic arithmetic operations (+, -, *, /)
- Parentheses for grouping
- Dot notation to reference other fields
Wildcard Calculations
For sections with AllowQuantity enabled, use wildcard syntax for aggregate calculations:
SectionName.*.FieldName
: Refers to the FieldName property of all items in SectionName.
[Inventory]
DatasetType (system) = items
AllowQuantity (system) = true
TotalWeight (calculated) = Inventory.*.Weight * Inventory.*.Quantity
Best Practices
- GUIDs: Leave this blank, and the system will generate a GUID for you. This ensures uniqueness across datasets and templates.
- Versioning: Use semantic versioning for your files to manage updates and breaking changes.
- Naming Convention: Strictly use PascalCase for all SectionNames and FieldNames.
- Nested sections: Use dot notation to create logical hierarchies but avoid excessive nesting.
- Dependencies: Explicitly list all required datasets in templates.
- Validation: Before use, validate that a file's structure is correct and all references are valid.