WowAddons

World of Warcraft Forever API · table.md, for your AI

table

12 functions, as Blizzard documents them for Forever 1.60.1 (70959).

Making an addon with an AI? Tell it: Read https://wowaddons.gg/agents.md, then make me a World of Warcraft Forever addon that …, try it with me in the game, and publish it. It checks every call against this API before you try it in the game, then publishes it here. How it works.

Functions

table.contains

containsValue = table.contains(table, [value])

Returns true if any value in the table compares equal to the specified value.

Arguments

tabletableThe table to search.
valueany may be nilThe value for which to search.

Returns

containsValueboolTrue if any entry in the table has the specified value.

table.count

count = table.count(table)

Returns the number of entries in the table.

Its returns can be secret values (in some instances and fights): guard them before any arithmetic.

Arguments

tabletableThe table whose entries will be counted.

Returns

countnumberThe number of entries in the table.

table.create

table = table.create(arraySizeHint, [nodeSizeHint])

Creates an empty table with storage preallocated for the specified number of array and non-array entries.

Arguments

arraySizeHintnumberThe number of array entries for which to preallocate storage.
nodeSizeHintnumber default 0The number of non-array entries for which to preallocate storage.

Returns

tabletable

table.indexof

index = table.indexof(table, [value])

Returns the first integer index whose value compares equal to the specified value, searching consecutively from index 1 until the first nil value.

Arguments

tabletableThe table to search.
valueany may be nilThe value for which to search.

Returns

indexnumber may be nilThe first matching index, or nil if no match is found.

table.freeze

frozen = table.freeze(table)

Marks a supplied table as frozen, preventing any modifications to its contents, or replacement of its metatable. If the table has a pre-existing metatable with a '__newindex' table or function, assignments will pass through without raising errors. For tainted code, only tables created by the same addon making this function call are permitted to be frozen.

Arguments

tabletableThe table to freeze.

Returns

frozentableThe supplied table, passed through.

table.keys

keys = table.keys(table)

Returns an array containing the keys of the specified table.

Arguments

tabletableThe table whose keys will be returned.

Returns

keysanyAn array containing the table's keys. The order of the returned keys is unspecified.

table.getcountinfo

numEntries, numPositiveIntegerKeys, maxPositiveIntegerKey = table.getcountinfo(table)

Returns detailed information about the number and distribution of entries in the table.

Its returns can be secret values (in some instances and fights): guard them before any arithmetic.

Arguments

tabletableThe table to inspect.

Returns

numEntriesnumberThe total number of entries in the table.
numPositiveIntegerKeysnumberThe number of entries with positive integral keys.
maxPositiveIntegerKeynumberThe largest positive integral key in the table, or zero if no such keys were found.

table.values

values = table.values(table)

Returns an array containing the values of the specified table.

Arguments

tabletableThe table whose values will be returned.

Returns

valuesanyAn array containing the table's values. The order of the returned values is unspecified.

table.isempty

empty = table.isempty(table)

Returns true if the table contains no entries.

Its returns can be secret values (in some instances and fights): guard them before any arithmetic.

Arguments

tabletable

Returns

emptyboolTrue if the table contains no entries; otherwise false.

table.isfrozen

frozen = table.isfrozen(table)

Returns true if a table has been marked as frozen.

Arguments

tabletableThe table to inspect.

Returns

frozenboolTrue if the table has been made read-only; otherwise false.

table.removeunordered

value = table.removeunordered(table, [index])

Removes the value at the specified integer index by replacing it with the last value in the array and shortening the array by one element. The order of values in the array is not preserved.

Arguments

tabletableThe table from which to remove a value.
indexnumber may be nilThe integer index of the value to remove. If omitted, the last value is removed.

Returns

valueany may be nilThe removed value, or nil if the index is outside the array bounds.

table.removevalue

removedCount = table.removevalue(table, [value])

Removes all values equal to the specified value from the array portion of a table.

Arguments

tabletableThe table from which to remove values.
valueany may be nilThe value to remove.

Returns

removedCountnumberThe number of values removed.

It takes WowAddons

Free, for Windows, macOS and Linux: it puts the addon in your game in one click and keeps it up to date. Open it once, then press Install again.

WowAddons runs on your computer: open wowaddons.gg there.

Download for Windows