-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFOM_CookingScan.lua
More file actions
60 lines (51 loc) · 1.71 KB
/
Copy pathFOM_CookingScan.lua
File metadata and controls
60 lines (51 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
------------------------------------------------------
-- FOM_CookingScan.lua
------------------------------------------------------
local COOKING_SKILL_ID = 185;
FOM_Cooking = {};
local DifficultyToNum = {
["optimal"] = 4,
["orange"] = 4,
["medium"] = 3,
["yellow"] = 3,
["easy"] = 2,
["green"] = 2,
["trivial"] = 1,
["gray"] = 1,
["grey"] = 1,
}
function FOM_ScanTradeSkill()
local tradeSkillID, skillLineName, skillLineRank, skillLineMaxRank, skillLineModifier = C_TradeSkillUI.GetTradeSkillLine();
if not C_TradeSkillUI.IsTradeSkillReady()
or C_TradeSkillUI.IsDataSourceChanging()
or tradeSkillID ~= COOKING_SKILL_ID then
return -- should just get called again when ready
end
local allRecipeIDs = C_TradeSkillUI.GetAllRecipeIDs(FOM_RecipeIDs);
for _, recipeID in pairs(allRecipeIDs) do
local recipeInfo = C_TradeSkillUI.GetRecipeInfo(recipeID);
local difficulty;
if recipeInfo.learned then
difficulty = DifficultyToNum[recipeInfo.difficulty];
else
difficulty = 5;
end
local createdItemLink = C_TradeSkillUI.GetRecipeItemLink(recipeID);
local _, _, id = string.find(createdItemLink, "item:(%d+)");
local createdItemID = tonumber(id);
local numReagents = C_TradeSkillUI.GetRecipeNumReagents(recipeID);
if numReagents > 0 then
for reagentIndex = 1, numReagents do
local reagentLink = C_TradeSkillUI.GetRecipeReagentItemLink(recipeID, reagentIndex);
if reagentLink then
local _, _, itemID = string.find(reagentLink, "item:(%d+)");
local reagentItemID = tonumber(itemID);
if FOM_Cooking[reagentItemID] == nil then
FOM_Cooking[reagentItemID] = {};
end
FOM_Cooking[reagentItemID][createdItemID] = difficulty;
end
end
end
end
end