Skip to main content

Import, linked sources and table sets

The table document is the source of truth by default, and spreadsheets are a way to get data in and out. Teams whose designers work in a spreadsheet can instead link a table to a file, which makes the file the source of truth. Table sets stack several tables into one, for DLC, difficulty or mods.

Choosing a path​

PathDirectionUse it for
ClipboardbothQuick balance passes: copy a range out of a spreadsheet and paste it onto the grid, or copy grid cells back. See The table window.
One-off importinBringing a CSV, TSV or JSON file in once, with a preview of every change.
ExportoutWriting the whole table to CSV, TSV or JSON.
Linked sourceinA file that stays the source of truth. The table re-imports it whenever it changes.
note

Note

JSON is the only format that carries Curve, Array and Struct columns without loss. CSV and TSV are fine for everything else.

Importing a file​

  1. Open the table and switch to the Import tab.
  2. Leave Mode at One-off import.
  3. Enter a File (or press …) and press Load, or paste spreadsheet text straight into the text box.
  4. Set Missing rows: Keep leaves rows that are not in the file alone, Delete removes them.
  5. Press Preview. Nothing is written yet.
  6. Check Column mapping. Each source column is matched to a schema column by exact name, then ignoring case, then by the column's previous names. Use the drop-down to change a match. Columns that match nothing are marked skipped.
  7. Check Changes: added rows (+), changed rows (~) with each cell's old and new value, removed rows (−), the unchanged count, and every cell that does not parse, with its line, row and column.
  8. Fix any parse errors in the file, because they block the import. Then press Apply as one undo step.

File format​

  • CSV and TSV: the first line is the header. The separator is detected from the content. The key comes from the column named Key, or from the first column when there is none. Each cell is parsed with its column's text form, and quoting follows the usual CSV rules.
  • JSON: an array of objects, one per row, with a Key member and one member per column.
Key,Damage,FireRate,Rarity
rifle_mk2,36,2.5,Rare
pistol,12,4,Common
cannon,90,0.5,Epic
[
{ "Key": "rifle_mk2", "Damage": 36, "FireRate": 2.5, "Rarity": "Rare",
"Recoil": { "Points": [ [0, 0], [0.2, 1.5], [1, 0.4] ] } }
]

Exporting​

Press Export… on the Import tab and choose CSV, TSV or JSON. The whole table is written, using each column's text form.

Linking a table to a source file​

In linked mode the file is the source of truth, like the source file of a mesh:

  • The table re-transforms whenever the file changes, even while the editor is closed, because the file is one of the table's transform dependencies.
  • The transform reads the rows from the file. Only columns flagged Editor owned keep the values authored in the editor, which suits things the spreadsheet should not own, such as asset references picked in the editor.
  • In the grid, every column except the Editor owned ones is read-only.
  1. On the Import tab set Mode to Linked source (re-import on change).
  2. Enter the File, relative to a data directory, for example Source/Balance/weapons.csv.
  3. Choose Missing rows: whether a row that disappears from the file is dropped from the table or kept.
  4. A banner shows Linked to <file> and whether the rows in the editor match the file. Press Re-import now to copy the file's current content into the table, so the grid shows what the game will get. This is one undo step.
warning

Important

A cell in the file that does not parse fails the transform, and the error names the row and column. The game keeps the last good version of the table until the file is fixed.

Table sets​

A Data Table Set is an ordered stack of tables that use the same schema, merged into one table when the game loads it. Typical layers: the base game, a DLC, a difficulty, a platform, a mod.

Merge rules​

  • Layers apply in order. A row whose key is new adds a row.
  • A row whose key already exists overrides only the cells it authors. A cell left at its default in the layer keeps the value from below.
  • A row with the Removed flag (in the inspector's Row section) hides the row with that key.
  • A layer whose schema differs from the first layer's is skipped with an error in the log.

Setting up a set​

  1. Create the layer tables. They must use the same schema. Author only the rows and cells that change in each layer.
  2. Create a Data Table Set asset (category Logic).
  3. Add a layer per table and fill in its properties (below). The first layer is the base.
  4. Save. Open any layer table: its header now shows the set and a layer drop-down. Cells the layer does not author show the inherited value in dim italics, and cells it overrides are tinted.
  5. Load the set in the game instead of a single table (see C++ runtime).
PropertyDefaultDescription
SetNamenoneThe merged table's name, used in logs and events.
Layer · LayerNamenoneThe name game code uses to switch the layer on and off. Must be unique within the set.
Layer · TablenoneThe layer's Data Table asset.
Layer · EnabledByDefaultonWhether the layer is merged when the set loads.
Layer · ConditionemptyA note for game code, such as an entitlement id or a difficulty name. The engine does not read it. The game decides and calls SetLayerEnabled.
Layer · OverrideOnlyoffLogs a warning when this layer adds a key that no earlier layer has. Use it for layers that should only tweak existing rows.

Switching layers at runtime​

// The player bought the DLC.
pWeaponsSet->SetLayerEnabled("DLC_Frost", true);

The set merges again and broadcasts plDataTableEvent::Type::Changed on its m_Events. Row views taken before the change point at the old merged table: look rows up again after the event. The same call is available to scripts as DataTables.SetLayerEnabled.