Skip to content

Table

clearTable(luaMap): void

Defined in: packages/isaacscript-common/src/functions/table.ts:8

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.

LuaMap<AnyNotNil, unknown>

void


copyUserdataValuesToTable(object, keys, luaMap): void

Defined in: packages/isaacscript-common/src/functions/table.ts:15

Helper function to copy specific values from a userdata object (e.g. Vector) to a table.

unknown

readonly string[]

LuaMap<string, unknown>

void


getBooleansFromTable(luaMap, objectName, …keys): readonly boolean[]

Defined in: packages/isaacscript-common/src/functions/table.ts:43

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.

LuaMap<string, unknown>

string

…readonly string[]

readonly boolean[]


getNumbersFromTable(luaMap, objectName, …keys): readonly number[]

Defined in: packages/isaacscript-common/src/functions/table.ts:75

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.

LuaMap<string, unknown>

string

…readonly string[]

readonly number[]


getStringsFromTable(luaMap, objectName, …keys): readonly string[]

Defined in: packages/isaacscript-common/src/functions/table.ts:114

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.

LuaMap<string, unknown>

string

…readonly string[]

readonly string[]


isTableEmpty(luaMap): boolean

Defined in: packages/isaacscript-common/src/functions/table.ts:139

Helper function to check if a Lua table has 0 keys.

LuaMap<AnyNotNil, unknown>

boolean


iterateTableInOrder<K, V>(luaMap, func, inOrder?): void

Defined in: packages/isaacscript-common/src/functions/table.ts:164

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.

K extends AnyNotNil

V

LuaMap<K, V>

The table to iterate over.

(key, value) => void

The function to run for each iteration.

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.

void


tableHasKeys(luaMap, …keys): boolean

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

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.

LuaMap<AnyNotNil, unknown>

…readonly string[]

boolean