Thread Tools Display Modes
12/17/16, 10:02 PM   #1
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
Results from Built-In Functions

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?
  Reply With Quote
12/18/16, 04:26 AM   #2
JoKim
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 7
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?
Code:
function YourFunction(ItemTraitType, traitDescription, traitSubtype, traitSubtypeName, traitSubtypeDescription)
    local yourvariable = traitSubtype
end
Trick is to list them all in the right order, since it's not the name but simply the order things are being send YourFunction(1st item, 2nd item, 3rd item, etc)
Doesn't matter if you don't do anything with the rest.

Last edited by JoKim : 12/18/16 at 04:36 AM. Reason: Clarification
  Reply With Quote
12/18/16, 04:28 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
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
12/18/16, 05:57 PM   #4
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
Originally Posted by votan View Post
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))
Exactly what I needed. Thanks!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Results from Built-In Functions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off