Schemas and column types
A Data Schema asset is the row type of one or more tables. It is an ordered list of columns. Each column has a name, a type, flags, an optional default and validation rules. Tables, table sets, store tables and the generated C++ headers all read the same schema, so a column is defined once.
Edit a schema from the Schema tab of any table that uses it, or open the schema asset on its own. Both edit the same document.
Column types
The set of types is fixed, so that every column packs into a fixed-width runtime array and every type has a grid editor, a text form for CSV and the clipboard, and a script mapping.
| Type | Holds | Text form (CSV, clipboard) | C++ read |
|---|---|---|---|
Bool | true or false | true / false / 1 / 0 | GetBool, Get<bool> |
Int | 32-bit signed integer | 42 | GetInt, Get<plInt32> |
Float | 32-bit float | 1.25 | GetFloat, Get<float> |
Name | A short identifier, stored hashed | fire_damage | GetName → plHashedString |
String | Any text | any text | GetString → plStringView |
Text | Player-facing text, translated on read. See Text columns. | the source-language text | GetText → translated plStringView |
Enumeration | One value of a reflected enum type, or of an inline list | the value name: Epic | GetInt |
Flags | Any combination of a reflected bitflags type, or of an inline list | Fire|Ice | GetUInt |
Tags | A set of tags | Weapon.Ranged;Heavy | GetTags, HasTag |
Vec2 / Vec3 / Vec4 | Float vectors | (1, 0, 0) | GetVec2 / GetVec3 / GetVec4 |
Color | Linear colour | #ffcc00 | GetColor |
Time | A duration, stored in seconds | 1.5s | GetTime → plTime |
Angle | An angle, stored in radians, shown in degrees | 90deg | GetAngle → plAngle |
Asset | A reference to an asset | asset GUID or path | GetAssetId → resource id to pass to LoadResource |
Row | A reference to a row of another table (or of the same table) | the row key: ammo_762 | GetRef → plDataRowRef, GetRefRow → the row |
Curve | A 1D curve | JSON: { "Points": [ [0, 1], [1, 2] ] } | GetCurve → const plCurve1D* |
Array | A list of one scalar element type: Bool, Int, Float, Enumeration, Flags, Name, String, Text, Vec2, Vec3, Vec4, Color, Time or Angle | [a;b;c] | GetArrayCount, GetArrayElement |
Struct | A dictionary of named values | JSON object | GetStruct → const plVariantDictionary* |
Note
Curve, Array and Struct cells have no compact text form. The grid shows them read-only. Edit them in the inspector's JSON editor or import them from a JSON file. CSV cannot carry them losslessly.
Enumeration and Flags values
Set Value type to a reflected enum or bitflags type (for example one of your game's enums) to use its values. Leave it empty and enter a comma-separated list in Inline values instead. An inline Enumeration value is stored as its position in the list (the first value is 0), and an inline Flags value is the bit at that position. Reordering an inline list therefore changes what existing cells mean. Append new values at the end.
Column flags
| Flag | Effect |
|---|---|
| Required | An empty cell is an error that stops the transform. |
| Unique | Two rows with the same value are an error. |
| Indexed | The transform builds a sorted index, so an equality query on this column is a binary search instead of a scan. Worth it for columns the game filters on often, such as a class or a rarity. |
| Strict | Range, length and pattern violations are errors instead of warnings. |
| Derived | The column is computed from Expression and cannot be edited. See below. |
| Editor owned | For a table with a linked source file: this column keeps the value authored in the editor instead of taking the file's value, and stays editable in the grid. |
| Acyclic | For a Row column that points into the same table, such as an upgrade chain: a cycle of references is reported as a warning. |
| Picker column | The row picker shows this column next to the key. With no picker columns, it shows the first two ordinary columns. |
Column properties
| Property | Applies to | Description |
|---|---|---|
| Name | all | The name used by code, scripts, queries and CSV headers. Renaming records the old name, see below. |
| Type | all | One of the types above. Changing it converts the cells of the current table, see below. |
| Default value | all | The value of a cell a row does not set. Empty means the type's default (0, false, empty text, white for Color). |
| Validate against a range, Minimum, Maximum | numeric types | A value outside the range is a warning, or an error when the column is Strict. The Validation tab can clamp all out-of-range cells at once. |
| Value type, Inline values | Enumeration, Flags | Where the values come from, see above. |
| Asset type | Asset | An asset type filter such as CompatibleAsset_Mesh. A reference to an asset of another type is an error. Empty accepts any asset. |
| Target table | Row | The table the column's row keys belong to. A key that does not exist there is an error. |
| Element type, Max count | Array | The element type and the most elements a cell may hold (0 means no limit). |
| Max length, Pattern | Name, String, Text | The longest allowed text, and a regular expression every value must match completely. Both produce warnings, or errors when the column is Strict. |
| Tag category | Tags | The tag category the column's tags come from. |
| Expression | Derived | The formula, see below. |
| Previous names | all | Names the column had before. Filled in automatically on rename. |
| Description | all | Shown as the column's tooltip in the grid and written into generated code. |
Derived columns
A derived column is computed from the other numeric columns of the same row: Bool, Int, Float, Enumeration, Flags, Time and Angle columns, and derived columns declared earlier in the schema. It must itself have one of those types.
- Add a column, give it a numeric type and tick Derived.
- Enter the Expression using the other columns' names, e.g.
Damage * FireRateormax(Damage - Armor, 1). The expression language is the engine's expression VM, the same one particles and procedural generation use. - The line under the field shows compiles and the result for the first row, or the compile error in red.
The grid and the inspector show derived values shortly after each edit. The values that ship are computed when the table is transformed, so reading a derived column at runtime costs the same as reading any other column. A derived value that is not a finite number, for example after a division by zero, is an error that names the row.
Renaming a column
Rename a column in the Schema tab. The old name is appended to Previous names and every row of the current table is updated in the same step. The previous names keep everything else working:
- Other tables that use the schema still find their cells under the old name when they are transformed.
- CSV and JSON imports match a header against the previous names too.
- Saved data store rows are matched by previous names when a save game is loaded, so a renamed column keeps its saved values.
Important
Do not delete a column and add a new one to rename it. Saved games and other tables would lose the values.
Changing a column's type
Changing the Type converts the cells of the table you are editing, as one undo step:
| From → To | Result |
|---|---|
| Int ↔ Float | Values are kept. Float to Int rounds, and the summary says how many values changed. |
| String or Name → Enumeration | Text is matched against the value names, ignoring case. Values that match nothing are listed. |
| anything → String | Each value becomes its text form. |
| anything else | The editor asks before it clears the cells that cannot be converted. |
Other tables that use the same schema are not converted. The Schema tab lists them. Open each one to convert its cells, otherwise they will report conversion errors on their next transform.
Generated C++ row headers
A project with a C++ plugin can generate a typed struct per schema. It is opt-in twice: switch it on for the project in Project > Data Tables… > General > Generate code, and tick Generate code for this schema in the Schema tab of each schema that should have a header. Press Generated code in the Schema tab to preview the output.
Saving the schema writes Generated/DataTables/<SchemaName>.h into the C++ plugin's source folder, plus <SchemaName>.schema.json, a manifest for C# tooling. A file whose content has not changed is not rewritten, so saving does not force a rebuild.
// Generated from Data/WeaponsRow.plDataSchemaAsset, do not edit.
struct plWeaponsRow : plDataRowView
{
plWeaponsRow() = default;
plWeaponsRow(const plDataRowView& row) : plDataRowView(row) {}
static constexpr plUInt64 SchemaHash = 0x6A1F...ULL;
bool MatchesSchema() const;
enum Column : plUInt32 { Column_Damage = 0, Column_FireRate = 1, Column_Rarity = 2, Column_DPS = 3 };
float Damage() const { return GetFloat(Column_Damage); }
float FireRate() const { return GetFloat(Column_FireRate); }
plInt32 Rarity() const { return GetInt(Column_Rarity); }
float DPS() const { return GetFloat(Column_DPS); }
};
plWeaponsRow weapon = pWeapons->GetRow("rifle_mk2");
if (weapon.IsValid() && weapon.MatchesSchema())
{
const float fDps = weapon.DPS();
}
Important
The accessors read fixed column positions. Call MatchesSchema() before reading: it compares the table's schema hash with the one the header was generated from. A table built from a changed schema, read through a stale header, would otherwise return values from the wrong columns. The hash changes when a column is added, removed, reordered, renamed or retyped, not when a range, description or pattern changes.
Enumeration columns are generated as plInt32 and Flags columns as plUInt32, with the value type named in a comment, because the generated header cannot include your game's enum headers.