Tables

Some table helpers.

Summary
TablesSome table helpers.
Functions
makeReadOnlyMakes a table and all recursive tables read-only
ropairsThe equivalent of “pairs” for a readonly table, since “pairs” won’t work.
findInTableFinds a value in a table.
matrixTableSplits a table into a number of given columns.

Functions

makeReadOnly

function ULib.makeReadOnly(t)

Makes a table and all recursive tables read-only

Parameters

tThe table to make read-only

Returns

The table read-only’fied

ropairs

function ULib.ropairs(t)

The equivalent of “pairs” for a readonly table, since “pairs” won’t work.

Parameters

tThe table

findInTable

function ULib.findInTable(t,
check,
init,
last,
recursive)

Finds a value in a table.  As opposed to table.HasValue(), this function will only check numeric keys, and will return a number of where the value is.

Parameters

tThe table to check
checkThe value to check if it exists in t.  Can be any type.
init(Optional, defaults to 1) The value to start from.
last(Optional, defaults to the length of the table) The value to end at.
recursive(Optional, default to false) If true, it will check any subtables it comes across.

Returns

The number of the key where check resides, false if none is found.  If init > last it returns false as well.

matrixTable

function ULib.matrixTable(t,
columns)

Splits a table into a number of given columns.  Does not change original table.

Parameters

tThe table to split columns, The number of columns to create

Returns

The new table with the column being the first key and the row being the second key.

Revisions

v2.10Initial
function ULib.makeReadOnly(t)
Makes a table and all recursive tables read-only
function ULib.ropairs(t)
The equivalent of “pairs” for a readonly table, since “pairs” won’t work.
function ULib.findInTable(t,
check,
init,
last,
recursive)
Finds a value in a table.
function ULib.matrixTable(t,
columns)
Splits a table into a number of given columns.
Close