GetAlchemyItemTraits

From ESOUI Wiki

Jump to: navigation, search

Returns a variable number of values representing all of the alchemy traits for an item. The number of return values per trait is represented by the constant ALCHEMY_TRAIT_STRIDE. The values returned for each trait are:

If the player hasn't learned a trait, then all of its fields will be nil (though Zenimax's Lua code also checks for an empty string as the trait name); however, the game will still return the correct number of nils (i.e. if the player doesn't know any of a reagent's four traits, then you get twenty nils). As such, the only way to properly count the number of traits that an item has is to pass this function's return values directly into a varargs function, use select("#", ...) inside of that varargs function, and divide the result of that by ALCHEMY_TRAIT_STRIDE.

Contents

Arguments

bagId
A number representing the bag to check; it must be one of the built-in Bag values.
slotIndex
The numeric index of the slot in that bag which should be checked. For most bags, this is a number ranging from 1 to the size of the bag.

Return values

These values are returned for each trait. If an alchemy item has two traits, then there will be ten return values — five per trait. If the trait hasn't been learned by the player, then all five of its values will be nil.

trait
The name of the trait, as a string.
icon
The texture path to the trait's basic icon.
matchIcon
The texture path for the icon shown when the trait can be used in the current potion. In the console UI, this is the trait icon with a green border.
cancellingTrait
The name of this trait's opposite.
conflictIcon
The texture path for the icon shown when the trait conflicts with other traits present in the current potion. In the console UI, this is the trait icon with a red border.

Usage example

function handleTraits(...)
   local aCount    = select("#", ...)
   local numTraits = aCount / ALCHEMY_TRAIT_STRIDE
   local traitData = {}
   for i = 1, numTraits do
      local offset = (i - 1) * ALCHEMY_TRAIT_STRIDE + 1
      traitData[i] = {
         name         = select(offset, ...),
         icon         = select(offset + 1, ...),
         matchIcon    = select(offset + 2, ...),
         cancellingTraitName = select(offset + 3, ...),
         conflictIcon = select(offset + 4, ...),
      }
   end
   return traitData
end
local traitsForItem = handleTraits(GetAlchemyItemTraits(bagIndex, slotIndex))

See also

External links

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox