# SessionZero Data

## Datapack

Datapacks contain multiple Datasets as well as their DatasetObject Template files and other resource files

### Datapack Archive File Structure
```text
datapack_name/
├─ resources/
│  ├─ images/
│  ├─ audio/
├─ datasets/
│  ├─ dataset_name/
│  │  ├─ objects/
│  │  │  ├─ object_name.szo
│  │  ├─ dataset.meta
├─ templates/
│  ├─ template_name.sztl
├─ datapack.meta
├─ README.md
├─ icon.png
```

### `datapack.meta` file
```json
{
    "name": "SessionZero Core",
    "id": "sz_core",
    "uuid": "95c6d3c9-3213-4256-b3db-b004d0fb95b7",
    "version": "1.0.0",
    "compatible_systems": "sz_core, d20",
    "description": "SessionZero Core Datapack"
}
```

## Dataset Metadata (`dataset.meta`) File Definition

- The `id` field MUST be unique from other datasets listed withing the containing datapack
- `dataset_type` is an arbitrary string that is used to identify what the general "type" of data the dataset contains
- `object_template` is the template definition used for creating dataset objects. It must be present in the parent datapack's `templates/` directory

```json
{
    "name": "SessionZero Core Items",
    "id": "core_items",
    "icon": "icons/items_icon",
    "description": "A set of simple items",
    "dataset_type": "item",
    "object_template": "core_item"
}
```

## DatasetObject Template File

- Metadata fields required for data object templates:
    - `template_type`: must be `data`.
    - `id`: denotes the template's id; must be unique within the datapack.
    - `uuid`: can be left at 0, a uuid will be assigned when uploading to the SessionZeroDB.
    - `version`: must follow semantic versioning.
    - `data_type`: is an arbitrary value used to denote what kind of dataset type the template is for.
    - `compatible_systems`: is arbitrary and only reflects if the template can be used in a datapack according to its own `compatible_systems` value.
    - `description`

- Supported Field Types for `data` template types:
  - text
  - textblock
  - bool
  - number

```toml
[metadata]
template_type = "data"
id = "core_item"
uuid = 0
version = "1.0.0"
data_type = "item"
compatible_systems = ["sz_core", "d20"]
description = """
Core SessionZero item template
"""

[name]
type = "text"

[description]
type = "textblock"

[consumable]
type = "bool"
default_value = false

# -- Stats group --
[stats.value]
type = "number"

[stats.weight]
type = "number"

[stats.modifiers.base]
type = "number"
default_value = 1

```

## DatasetObject object (.szo file)

An instanced DatasetObject should only contain simple fields and values, no object references or formulas

```json
{
  "Id": "",
  "Uuid": "0",
  "template_id": "core_item",
  "fields": {
    "name": "Excalibur",
    "description": null,
    "consumable": true,
    "stats": {
      "value": 10,
      "weight": 2,
      "modifiers": {
        "base": 5
      }
    }
  }
}
```