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)