Table
Functions
clearTable
▸ clearTable(luaMap
): void
In a Map
, you can use the clear
method to delete every element. However, in a LuaMap
, the
clear
method does not exist. Use this helper function as a drop-in replacement for this.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <AnyNotNil , unknown > |
Returns
void
Defined in
packages/isaacscript-common/src/functions/table.ts:8
copyUserdataValuesToTable
▸ copyUserdataValuesToTable(object
, keys
, luaMap
): void
Helper function to copy specific values from a userdata object (e.g. Vector
) to a table.
Parameters
Name | Type |
---|---|
object | unknown |
keys | readonly string [] |
luaMap | LuaMap <string , unknown > |
Returns
void
Defined in
packages/isaacscript-common/src/functions/table.ts:15
getBooleansFromTable
▸ getBooleansFromTable(luaMap
, objectName
, ...keys
): readonly boolean
[]
Helper function to safely get boolean values from a Lua table. Will throw an error if the specific value does not exist on the table.
This function is variadic, meaning that you can specify N arguments to get N values.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <string , unknown > |
objectName | string |
...keys | readonly string [] |
Returns
readonly boolean
[]
Defined in
packages/isaacscript-common/src/functions/table.ts:43
getNumbersFromTable
▸ getNumbersFromTable(luaMap
, objectName
, ...keys
): readonly number
[]
Helper function to safely get number values from specific keys on a Lua table. If the values are strings, they will be converted to numbers. Will throw an error if the specific value does not exist on the table or if it cannot be converted to a number.
This function is variadic, meaning that you can specify N arguments to get N values.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <string , unknown > |
objectName | string |
...keys | readonly string [] |
Returns
readonly number
[]
Defined in
packages/isaacscript-common/src/functions/table.ts:75
getStringsFromTable
▸ getStringsFromTable(luaMap
, objectName
, ...keys
): readonly string
[]
Helper function to safely get string values from a Lua table. Will throw an error if the specific value does not exist on the table.
This function is variadic, meaning that you can specify N arguments to get N values.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <string , unknown > |
objectName | string |
...keys | readonly string [] |
Returns
readonly string
[]
Defined in
packages/isaacscript-common/src/functions/table.ts:114
isTableEmpty
▸ isTableEmpty(luaMap
): boolean
Helper function to check if a Lua table has 0 keys.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <AnyNotNil , unknown > |
Returns
boolean
Defined in
packages/isaacscript-common/src/functions/table.ts:139
iterateTableInOrder
▸ iterateTableInOrder<K
, V
>(luaMap
, func
, inOrder?
): void
Helper function to iterate over a table deterministically. This is useful because by default, the
pairs
function will return the keys of a Lua table in a random order.
This function will sort the table entries based on the value of the key.
This function will only work on tables that have number keys or string keys. It will throw a run-time error if it encounters a key of another type.
Type parameters
Name | Type |
---|---|
K | extends AnyNotNil |
V | V |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
luaMap | LuaMap <K , V > | undefined | The table to iterate over. |
func | (key : K , value : V ) => void | undefined | The function to run for each iteration. |
inOrder | boolean | true | Optional. Whether to iterate in order. True by default. You can dynamically set to false in situations where iterating randomly would not matter and you need the extra performance. |
Returns
void
Defined in
packages/isaacscript-common/src/functions/table.ts:164
tableHasKeys
▸ tableHasKeys(luaMap
, ...keys
): boolean
Helper function to check if a Lua table has all of the provided keys.
This function is variadic, meaning that you can specify as many arguments as you want to check for.
Parameters
Name | Type |
---|---|
luaMap | LuaMap <AnyNotNil , unknown > |
...keys | readonly string [] |
Returns
boolean