View Single Post
12/18/16, 04:28 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 578
Originally Posted by Rhyono View Post
I'm sure this has a very simple answer, but: How do I choose just a piece of the return from ZoS functions that have multiple? I thought it might be a table, but doing it that way didn't work.

For example (from the wiki):
GetItemLinkTraitInfo(string itemLink)
Returns: number ItemTraitType traitType, string traitDescription, number traitSubtype, string traitSubtypeName, string traitSubtypeDescription

If I wanted just the trait subtype, how would I write that?
There is a keyword "select" in Lua.
It starts taking the result variables beginning with the given index:
Code:
local r5, r6 = select(5, func(whatever))
also working:
Code:
local function abc(...)
  local count = select("#", ...)
  local p2, p3 = select(2, ...)
end
  Reply With Quote