Skip to main content

Scripting and tools

The DataTables script functions​

One set of functions reaches every scripting language. In Visual Script they are listed under DataTables. AngelScript reaches them through reflection. C# gets them from the generated engine bindings, and the exact C# signatures are in your project's generated PlasmaEngineBindings.g.cs.

A static table or table set is named by its asset GUID, as a string. A store table is named by the name it is declared with in the project settings, such as Inventory.

Static tables​

FunctionInputsReturnsNotes
HasRowTable, Keybool
GetCellTable, Key, ColumnvariantInvalid when the table, row or column does not exist. Text cells come back translated.
GetRowCountTableint
GetRowKeyAtTable, IndexstringRows in document order.
FindRowsTable, Queryvariant (array of keys)A text query such as Where(Rarity == Epic).OrderBy(DPS desc).Take(5). An empty query returns every key.
PickWeightedTable, Query, WeightColumn, Seedstring (key)A weighted random pick among the query's rows. The same seed returns the same row. Empty when nothing can be picked.
GetRefKeyTable, Key, ColumnstringThe key a Row column points at.
GetRefTableTable, Key, ColumnstringThe table a Row column points at, to use with GetCell.

Table sets​

FunctionInputsReturnsNotes
SetLayerEnabledTableSet, Layer, EnablednoneMerges the set again when the state changes.
IsLayerEnabledTableSet, Layerbool

Data store​

FunctionInputsReturnsNotes
StoreHasRowTable, Rowbool
StoreGetRowCountTableint
StoreGetRowKeyAtTable, Indexstring
StoreGetTable, Row, Columnvariant
StoreSetTable, Row, Column, ValueboolAdds the row when needed.
StoreIncrementTable, Row, Column, DeltaboolAdds the row when needed.
StoreAdd / StoreRemoveTable, Rowbool
StoreClearTablenone
StoreBeginTransaction, StoreCommit, StoreRollbacknonenoneSee Transactions.

To react to store changes in a script, add a Data Table Events component to the object and handle plMsgDataStoreChanged. See Reacting to changes.

Example: a loot roll in Visual Script​

  1. Add DataTables · PickWeighted. Set Table to the loot table's GUID, Query to Where(Tier <= 2), WeightColumn to Weight.
  2. Feed Seed from the crate's own seed so that the same crate always drops the same item.
  3. Pass the returned key to DataTables · StoreIncrement with Table Inventory, Column Count, Delta 1.

Live Data panel​

Panels > Show Panels > Live Data shows the tables of the running engine process, for example during Play. It is the fastest way to check what the game actually sees, and to give a tester 999 gold.

  • The title line shows whether an engine process is running, how many static and store tables it has, and the store generation. Without an engine process, the panel says so instead of showing old data.
  • The list on the left groups the tables: Static for loaded data tables, Store: Profile, Store: Slot and Store: Session for store tables, each with its row count.
  • Static tables are read-only here. Edit them in their table window and the change reaches the game by hot reload.
  • Store tables are editable: double-click a cell to change it, and use Add row and Remove row. Changed rows are highlighted briefly. The panel refreshes when the table changes in the game.
  • Large tables are shown in pages: the header says showing the first n of m rows.
  • The Query box runs a text query against the selected table, using the same code the game uses. Click one of the example chips below it to start from an example.
  • The log at the bottom lists incoming store events: type, table, row, column, old and new value.

Project settings​

Project > Data Tables… has two pages.

Page · settingDefaultDescription
Data Storeno tablesThe store table declarations, written to RuntimeConfigs/DataStore.ddl. See Data store & saving.
General · Generate codeoffAllows schemas marked Generate code for this schema to write C++ row headers and the schema manifest. See Generated C++ row headers.
General · Strict validationoffTurns every range, length and pattern warning in the project into a transform error.

The General page settings are stored in the project's Editor/DataTables.ddl.

Console commands​

Available in the game's console. The console is a Lua interpreter, so commands are called like functions with string arguments.

CommandArgumentsDescription
DataTables.DumptablePrints every row of a data table.
DataTables.Querytable, queryRuns a text query and prints the rows.
DataStore.DumptablePrints every row of a store table.
DataStore.Settable, row, column, valueWrites one store cell. The value text is parsed for the column's type.
DataTables.Dump("{ 4ec80001-6d67-1bc1-0100-64a7b3b6e00d }")
DataTables.Query("{ 4ec80001-6d67-1bc1-0100-64a7b3b6e00d }", "Where(Damage > 30).OrderBy(Damage desc).Take(4)")
DataStore.Set("Wallet", "gold", "Amount", "999")
DataStore.Dump("Wallet")

CVars​

CVarDefaultDescription
DataTables.LogQueriesfalseLogs every query with its matched and returned row counts and its time.
DataStore.ValidateWritestrue in Development buildsWarns when a store write is outside the column's range.