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.

Search on ESOUI Source Code GetAlchemyItemTraits(number Bag reagentBagId, number reagentSlotIndex)

Usage example

-- number bagIndex
-- number slotIndex
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, ...),
   return traitData
local traitsForItem = handleTraits(GetAlchemyItemTraits(bagIndex, slotIndex))
Personal tools