View Single Post
10-16-20, 09:37 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Many API functions that have many returns are being changed into returning a table.

Instead of the following:
local first, second, third = GetDataStuff()
-- first == "1st" and second == "2nd" and third == "3rd"
We get a table:
local table = GetDataStuff()
And the table looks like this:
table = {
first = "1st",
second = "2nd",
third = "3rd",
}
In your code, instead of:
local name, isHeader, isExpanded = C_Currency.GetCurrencyListInfo( i )
You use:
local table = C_Currency.GetCurrencyListInfo( i )
Then you can use the following:
table.name
table.isHeader
table.isHeaderExpanded
Because we no longer have control over the variable names returned, you'll have to consult API documentation ingame or on third party websites, or use the command /dump to print out the table. The following command will dump currency info on Coalescing Visions:
/dump C_Currency.GetCurrencyInfo(1755)
A negative side effect of returning tables is memory leaks. If you are using these table-returning functions a lot, such as every frame, each previous table is still there, just waiting to be garbage collected. Too much of these tables in a short time frame will cause the game to temporarily freeze or just slow down for less than a second in order for Lua to release some of this memory. It's not really an issue on beefy CPUs, but it is a very noticeable problem on weaker computers. Keep this in mind when using these functions.
  Reply With Quote