Table
Functions
Section titled “Functions”clearTable()
Section titled “clearTable()”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.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<AnyNotNil, unknown>
Returns
Section titled “Returns”void
copyUserdataValuesToTable()
Section titled “copyUserdataValuesToTable()”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.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
readonly string[]
luaMap
Section titled “luaMap”LuaMap<string, unknown>
Returns
Section titled “Returns”void
getBooleansFromTable()
Section titled “getBooleansFromTable()”getBooleansFromTable(
luaMap,objectName, …keys): readonlyboolean[]
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.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<string, unknown>
objectName
Section titled “objectName”string
…readonly string[]
Returns
Section titled “Returns”readonly boolean[]
getNumbersFromTable()
Section titled “getNumbersFromTable()”getNumbersFromTable(
luaMap,objectName, …keys): readonlynumber[]
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.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<string, unknown>
objectName
Section titled “objectName”string
…readonly string[]
Returns
Section titled “Returns”readonly number[]
getStringsFromTable()
Section titled “getStringsFromTable()”getStringsFromTable(
luaMap,objectName, …keys): readonlystring[]
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.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<string, unknown>
objectName
Section titled “objectName”string
…readonly string[]
Returns
Section titled “Returns”readonly string[]
isTableEmpty()
Section titled “isTableEmpty()”isTableEmpty(
luaMap):boolean
Defined in: packages/isaacscript-common/src/functions/table.ts:139
Helper function to check if a Lua table has 0 keys.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<AnyNotNil, unknown>
Returns
Section titled “Returns”boolean
iterateTableInOrder()
Section titled “iterateTableInOrder()”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.
Type Parameters
Section titled “Type Parameters”K extends AnyNotNil
V
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<K, V>
The table to iterate over.
(key, value) => void
The function to run for each iteration.
inOrder?
Section titled “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
Section titled “Returns”void
tableHasKeys()
Section titled “tableHasKeys()”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.
Parameters
Section titled “Parameters”luaMap
Section titled “luaMap”LuaMap<AnyNotNil, unknown>
…readonly string[]
Returns
Section titled “Returns”boolean
