ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Results from Built-In Functions (https://www.esoui.com/forums/showthread.php?t=6690)

Rhyono 12/17/16 10:02 PM

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?

JoKim 12/18/16 04:26 AM

Quote:

Originally Posted by Rhyono (Post 29145)
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.

votan 12/18/16 04:28 AM

Quote:

Originally Posted by Rhyono (Post 29145)
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


Rhyono 12/18/16 05:57 PM

Quote:

Originally Posted by votan (Post 29147)
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!


All times are GMT -6. The time now is 05:53 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI