View Single Post
04/12/14, 10:07 PM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
The profession id's can be grabbed from the skill line functions and the crafting type constants.

Item ID's you can get by extracting it from the Item Link, but other than that there is only an instance ID which can be the same for different items and also different for the same items. I haven't been able to pin down a pattern yet, possible the source of the loot, or the type of loot. Hard to say.

Anyways, here goes:

local skillType,skillIndex = GetCraftingSkillLineIndices(tradeSkill)
local skillName,skillRank = GetSkillLineInfo(skillType,skillIndex)

TradeskillType
CRAFTING_TYPE_ALCHEMY
CRAFTING_TYPE_BLACKSMITHING
CRAFTING_TYPE_CLOTHIER
CRAFTING_TYPE_ENCHANTING
CRAFTING_TYPE_INVALID
CRAFTING_TYPE_PROVISIONING
CRAFTING_TYPE_WOODWORKING

Either substitute the variable tradeSkill with the constant reference for the crafting skill you want to use or cycle through from 1 to 6 to store them all, or do what I did below, just to make sure. I can't remember if I tried a loop and it didn't work.

Here is a function I have been using to get a test addon working for one of my problem TODO areas :

Lua Code:
  1. local skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_ALCHEMY)
  2.     local skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  3.     local abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  4.     TradeSkills[CRAFTING_TYPE_ALCHEMY] = { Name = skillName, Icon = abilityIcon }
  5.  
  6.     skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_BLACKSMITHING)
  7.     skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  8.     abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  9.     TradeSkills[CRAFTING_TYPE_BLACKSMITHING] =  { Name = skillName, Icon = abilityIcon }
  10.  
  11.  
  12.     skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_CLOTHIER)
  13.     skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  14.     abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  15.     TradeSkills[CRAFTING_TYPE_CLOTHIER] =   { Name = skillName, Icon = abilityIcon }
  16.  
  17.     skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_ENCHANTING)
  18.     skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  19.     abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  20.     TradeSkills[CRAFTING_TYPE_ENCHANTING] =     { Name = skillName, Icon = abilityIcon }
  21.  
  22.     skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_PROVISIONING)
  23.     skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  24.     abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  25.     TradeSkills[CRAFTING_TYPE_PROVISIONING] =   { Name = skillName, Icon = abilityIcon }
  26.    
  27.     skillType,skillIndex = GetCraftingSkillLineIndices(CRAFTING_TYPE_WOODWORKING)
  28.     skillName,skillRank  = GetSkillLineInfo(skillType, skillIndex)
  29.     abilityName,abilityIcon = GetSkillAbilityInfo(skillType, skillIndex, 1)
  30.     TradeSkills[CRAFTING_TYPE_WOODWORKING] =    { Name = skillName, Icon = abilityIcon }

That aside, lets see what other questions you asked ...

You can use a for loop to cycle through a table or set as you mentioned.

Example Table.
tableName = { 23, 56, "alpha", true }
In this example the key would be a number and the data would be the values in this table or list or set

Lua Code:
  1. tableName = {
  2.     name = "Stuart",
  3.     address = "123 Letsby Avenue",
  4.     single = "true" ,
  5.     ["No of Children"] = 3,
  6.     Children = {
  7.          "Stuart",
  8.          "Alison",
  9.          "William"
  10.     }
  11. }

In this example, notice that each value now has a key and value set up and oh look, one of the keys has had to be boxed up as it is a multi word string, and one of the values contains another table.

Lua Code:
  1. for key,data in pairs(tableName) do
  2.      -- data could be another table so another cycle will need to be done to access that one etc.
  3.      if type(data) == "table" then
  4.         for key2,data2 in pairs(data) do
  5.             -- work with this level of keys or data
  6.         end
  7.      else
  8.         -- work with key or data,
  9.      end
  10. end

As to other functionality in the addons you would have to look at the addon as a whole as the data it is looking at could be stored in a certain way to make it work.

The CheckIn... Function though is doing its work correctly. If it comes across a valid match it will return out of the function with the value true telling the calling statement to know that a match has been found. If it doesn't find it by the time it has reached the end of the table it is assumed that no match is found and will return false. The only reason this may be wrong is if there was a case specific issue in play. But in ESO case identifies what type of data it is if you want to use it that way.

For example.
In my gatherer addon I store both node findings ( "Iron Ore", "Bugloss", "Jute" ) and the items that can be looted from it such as ( "iron ore", "bugloss", "raw jute" ). Item names seem to be all in lower case and Object names are in mixed case.

It may be worth looking at the Lua manual for looking up the commands for this sort of stuff. A search on google should find several links.

Last edited by Xrystal : 04/12/14 at 10:23 PM.
  Reply With Quote