DirkScripts
Docs
Table
âšī¸ Shared Module - This can be used by both clients and the server
#lib.table.deepClone
Used to quickly copy a table, useful for global state values
lualocal copiedTable = lib.table.deepClone(table)
| Parameter | Type | Required | Description |
|---|---|---|---|
| table | Object, Array | true | Table to be copied |
#lib.table.findKeyInTable
Check through a table for a set key
lualocal foundData = lib.table.findKeyInTable(tbls, key)
| Parameter | Type | Required | Description |
|---|---|---|---|
| tbls | String, Object | true | Table to be searched |
| key | String, Number | true | Key to be found |
#lib.table.includes
Check if a value is present in a table
lualocal found = lib.table.includes(table, value, recursive)
| Parameter | Type | Required | Description |
|---|---|---|---|
| table | Object, Array | true | Table to be searched |
| value | Object | true | Value to be found |
| recursive | Boolean | false | Check sub tables too |
#lib.table.convert
Convert data to different formats
lualocal data = lib.table.convert(_type, data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| _type | String | true | Type of data - vectors, items_sql, string, item_ox, convert_idexes |
| data | Any | true | Data to be converted |
#lib.table.count
Count entries in a table (works with non-sequential keys)
lualocal count = lib.table.count(table)
| Parameter | Type | Required | Description |
|---|---|---|---|
| table | table | yes | Table to count |
#lib.table.merge
Deep-merge two tables. Keys from t2 overwrite keys in t1.
lualocal merged = lib.table.merge(t1, t2, addDuplicateNumbers)
| Parameter | Type | Required | Description |
|---|---|---|---|
| t1 | table | yes | Base table |
| t2 | table | yes | Table to merge in |
| addDuplicateNumbers | boolean | no | If true, adds numeric values instead of overwriting |
#lib.table.wipe
Remove all entries from a table in-place
lualib.table.wipe(tbl)
| Parameter | Type | Required | Description |
|---|---|---|---|
| tbl | table | yes | Table to wipe |
#lib.table.freeze
Make a table read-only (errors on write)
lualocal frozen = lib.table.freeze(tbl)
| Parameter | Type | Required | Description |
|---|---|---|---|
| tbl | table | yes | Table to freeze |
#lib.table.compare
Deep-compare two tables for equality
lualocal equal = lib.table.compare(t1, t2)
| Parameter | Type | Required | Description |
|---|---|---|---|
| t1 | table | yes | First table |
| t2 | table | yes | Second table |
#lib.table.isArray
Check if a table is a sequential integer-indexed array
lualocal isArr = lib.table.isArray(tbl)
| Parameter | Type | Required | Description |
|---|---|---|---|
| tbl | table | yes | Table to check |
