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
table | table | The table to search. |
|---|---|---|
value | any may be nil | The value for which to search. |
Returns
containsValue | bool | True 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
table | table | The table whose entries will be counted. |
|---|
Returns
count | number | The 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
arraySizeHint | number | The number of array entries for which to preallocate storage. |
|---|---|---|
nodeSizeHint | number default 0 | The number of non-array entries for which to preallocate storage. |
Returns
table | table |
|---|
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
table | table | The table to search. |
|---|---|---|
value | any may be nil | The value for which to search. |
Returns
index | number may be nil | The 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
table | table | The table to freeze. |
|---|
Returns
frozen | table | The supplied table, passed through. |
|---|
table.keys
keys = table.keys(table)
Returns an array containing the keys of the specified table.
Arguments
table | table | The table whose keys will be returned. |
|---|
Returns
keys | any | An 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
table | table | The table to inspect. |
|---|
Returns
numEntries | number | The total number of entries in the table. |
|---|---|---|
numPositiveIntegerKeys | number | The number of entries with positive integral keys. |
maxPositiveIntegerKey | number | The 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
table | table | The table whose values will be returned. |
|---|
Returns
values | any | An 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
table | table |
|---|
Returns
empty | bool | True 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
table | table | The table to inspect. |
|---|
Returns
frozen | bool | True 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
table | table | The table from which to remove a value. |
|---|---|---|
index | number may be nil | The integer index of the value to remove. If omitted, the last value is removed. |
Returns
value | any may be nil | The 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
table | table | The table from which to remove values. |
|---|---|---|
value | any may be nil | The value to remove. |
Returns
removedCount | number | The number of values removed. |
|---|