DBTableType¶
Overview¶
A DBTableType config describes a table structure which DBRow configs use to store values.
A DBTable has a number of columns, each of which is assigned one or more ValueTypes, for example:
Column 1 = [ ValueType.INTEGER ] -- A column with one value
Column 2 = [ ValueType.NPC, ValueType.STRING ] -- A column with two values
Column 3 = [ ] -- A server-only column with no values
Each column can also optionally provide a default value, such as:
Column 1 = [ -1 ] -- A column with one default value
Column 2 = [ nil, "Nothing" ] -- A column also with one default value
Column 3 = [ ] -- A server-only column with no default values
These config types can be found within the config.DBTable table:
config.DBTable.INVENT_PERK_TABLE
config.DBTable["INVENT_PERK_TABLE"]
config.DBTable.FromID(8) -- config.DBTable.INVENT_PERK_TABLE
Info
An DBTableType is a Proxy usertype, which means it is safe to copy and store in your scripts.
It cannot, however, be used with any persistent storage.
Examples¶
-- Access a DBTable config directly by using its name
local dbTableCfg = config.DBTable.INVENT_PERK_TABLE
-- or by ID lookup
local dbTableCfg = config.DBTable.FromID(id.DBTable.INVENT_PERK_TABLE)
Constructors¶
Info
This usertype has no constructor, and you cannot create your own.
Methods¶
GetColumnValueCount¶
Returns the number of values in the given column.
| Parameter | Type | Description |
|---|---|---|
| columnIndex | Integer | The column index to check.Column index values are 1-indexed. |
| Returns | Description |
|---|---|
| Integer | How many values are available for the given column index. |
Example
GetColumnValueTypes¶
Returns all ValueTypes for each value in the given column.
| Parameter | Type | Description |
|---|---|---|
| columnIndex | Integer | The column index to check.Column index values are 1-indexed. |
| Returns | Description |
|---|---|
| [ ValueType ] | An array containing a ValueType for each value in the given column index. |
Example
-- Get all value types in the target column
-- [ ValueType.STRING ]
local valueTypesCol2 = config.DBTable.INVENT_PERK_TABLE:GetColumnValueTypes(2)
-- [ ValueType.INTEGER, ValueType.INTEGER, ValueType.INTEGER, ValueType.INTEGER ]
local valueTypesCol8 = config.DBTable.INVENT_PERK_TABLE:GetColumnValueTypes(8)
GetColumnHasDefaultValues¶
Returns whether a given column in the table has any default values.
| Parameter | Type | Description |
|---|---|---|
| columnIndex | Integer | The column index to check.Column index values are 1-indexed. |
| Returns | Description |
|---|---|
| Boolean | Whether the given column index can provide default values. |
Example
GetColumnDefaultValues¶
Returns all default values in the given column.
| Parameter | Type | Description |
|---|---|---|
| columnIndex | Integer | The column index to check.Column index values are 1-indexed. |
| Returns | Description |
|---|---|
| [ ? ] | An array containing each default value in the given column index.This array may be empty, or contain nil values.Use GetColumnValueTypes to determine the types of the values returned by this method. |
Example
Properties¶
Info
All properties are read-only.
| Name | Type | Description |
|---|---|---|
| id | Integer | The ID of this config type. |
| configName | String | The name of this config, i.e. "INVENT_PERK_TABLE". |
| typeName | String | The type of this config. Will always be "DBTable". |
| columnCount | Integer | The total number columns in this table. |