View Single Post
07-16-17, 05:30 AM   #5
Splynx
A Deviate Faerie Dragon
 
Splynx's Avatar
Join Date: Jul 2017
Posts: 10
Nice!

That is amazing - and knowing this exists actually changes a lot of my code

I did get around to finding a solution, and was about to post here - so for the sake of that..

Code:
function addon:GetTradeSkillFromCastName(name)
  local recipeIDs = C_TradeSkillUI.GetAllRecipeIDs();
  local tradeSkill = nil;

  for id = 1, #recipeIDs do
    local recipe = C_TradeSkillUI.GetRecipeInfo(recipeIDs[id]);
    if recipe.name == name then
      tradeSkill = recipe;
      break;
    end
  end

  return tradeSkill;
end

I felt I could be somewhat 100% certain that the cast name and the recipe name would always match.

But your solution is the clean way, and bypasses like some 500 iterations (if you are unlucky and it is last)

Last edited by Splynx : 07-16-17 at 05:33 AM.
  Reply With Quote