Skip to main content

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

NameType
luaMapLuaMap<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

NameType
objectunknown
keysreadonly string[]
luaMapLuaMap<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

NameType
luaMapLuaMap<string, unknown>
objectNamestring
...keysreadonly 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

NameType
luaMapLuaMap<string, unknown>
objectNamestring
...keysreadonly 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

NameType
luaMapLuaMap<string, unknown>
objectNamestring
...keysreadonly 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

NameType
luaMapLuaMap<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

NameType
Kextends AnyNotNil
VV

Parameters

NameTypeDefault valueDescription
luaMapLuaMap<K, V>undefinedThe table to iterate over.
func(key: K, value: V) => voidundefinedThe function to run for each iteration.
inOrderbooleantrueOptional. 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

NameType
luaMapLuaMap<AnyNotNil, unknown>
...keysreadonly string[]

Returns

boolean

Defined in

packages/isaacscript-common/src/functions/table.ts:205