-
Notifications
You must be signed in to change notification settings - Fork 11
/
engcrafts.lua
166 lines (145 loc) · 7.56 KB
/
engcrafts.lua
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
function EngBags_Crafts()
-- load craft info (Enchanting)
if (GetNumCrafts() > 0) then
local craftName, craftSubSpellName, craftType, numAvailable, isExpanded;
local craftItemLink;
local tradeskillName, currentLevel, maxLevel = GetCraftDisplaySkillLine();
local a,b,c,d;
local reagentItemLink;
local tmpval, tmptooltip, idx, tmptooltip2;
-- hunter training window shows up as a craft with a nil tradeskillName
if (tradeskillName ~= nil) then
if (EngBagsConfig[EngBags_PLAYERID] == nil) then
EngBagsConfig[EngBags_PLAYERID] = {};
end
if (EngBagsConfig[EngBags_PLAYERID]["tradeskills"] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskills"] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskills"][tradeskillName] = date("%y%m%d%H%M%S");
EngBank_SetTradeSkills();
if (EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"] = {};
end
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName] = {}; -- wipe it out, we're refreshing it now anyway
if (GetNumCrafts() > 0) then
for i = 1, GetNumCrafts() do
craftName, craftSubSpellName, craftType, numAvailable, isExpanded = GetCraftInfo(i);
craftItemLink = GetCraftItemLink(i);
-- remember: a craft might just be a skill and not a physical item
if ( (craftItemLink ~= nil) and (type(craftItemLink) == "string") ) then
for a,b,c,d in string.gfind(craftItemLink, "(%d+):(%d+):(%d+):(%d+)") do
craftItemLink = ""..a..":0:"..c..":0";
end
if ( EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink] == nil ) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink][tradeskillName] = 1;
end
-- build the complete info about tradeskills, this is for exporting data
-- so now I store by craftName instead of craftItemLink
if ( (EngBank_BuildTradeList[tradeskillName] == nil) and (EngBagsConfig["build_trade_list"] == 1) ) then
EngBank_tt:SetCraftSpell(i);
if (EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName] == nil) then
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName] = {};
end
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName]["item"] = EngBags_ExtractTooltip("EngBank_tt");
end
if (GetCraftNumReagents(i) > 0) then
for i2 = 1, GetCraftNumReagents(i) do
reagentItemLink = GetCraftReagentItemLink(i,i2);
if (reagentItemLink ~= nil) then
for a,b,c,d in string.gfind(reagentItemLink, "(%d+):(%d+):(%d+):(%d+)") do
reagentItemLink = ""..a..":0:"..c..":0";
end
if (EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink][tradeskillName] = 1;
if ( (EngBank_BuildTradeList[tradeskillName] == nil) and (EngBagsConfig["build_trade_list"] == 1) ) then
EngBank_tt:SetCraftItem(i,i2);
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink] = EngBags_ExtractTooltip("EngBank_tt");
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["n"],
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["t"],
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["c"] = GetCraftReagentInfo(i,i2);
end
end
end
end
end
end
EngBank_BuildTradeList[tradeskillName] = 1; -- only do the exhaustive load once
end
end
end
function EngBags_Trade()
-- load tradeskill info (every other trade)
if (GetNumTradeSkills() > 0) then
local craftName, craftSubSpellName, craftType, numAvailable, isExpanded;
local craftItemLink;
local tradeskillName, currentLevel, maxLevel = GetTradeSkillLine();
local a,b,c,d;
local reagentItemLink;
if (EngBagsConfig[EngBags_PLAYERID] == nil) then
EngBagsConfig[EngBags_PLAYERID] = {};
end
if (EngBagsConfig[EngBags_PLAYERID]["tradeskills"] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskills"] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskills"][tradeskillName] = date("%Y%m%d%H%M%S");
EngBank_SetTradeSkills();
if (EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"] = {};
end
if (EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"] = {};
end
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName] = {};
for i = 1, GetNumTradeSkills() do
craftName, craftType, numAvailable, isExpanded = GetTradeSkillInfo(i);
craftItemLink = GetTradeSkillItemLink(i);
if (craftType ~= "header") then
TradeSkillFrame_SetSelection(i)
TradeSkillFrame_Update();
if ( (craftItemLink ~= nil) and (type(craftItemLink) == "string") ) then
for a,b,c,d in string.gfind(craftItemLink, "(%d+):(%d+):(%d+):(%d+)") do
craftItemLink = ""..a..":0:"..c..":0";
end
if ( EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink] == nil ) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskill_production"][craftItemLink][tradeskillName] = 1;
-- build the complete info about tradeskills, this is for exporting data
if ( (EngBank_BuildTradeList[tradeskillName] == nil) and (EngBagsConfig["build_trade_list"] == 1) ) then
if (EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName] == nil) then
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName] = {};
end
EngBank_tt:SetTradeSkillItem(i);
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName]["item"] = EngBags_ExtractTooltip("EngBank_tt");
end
if (GetTradeSkillNumReagents(i) > 0) then
for i2 = 1, GetTradeSkillNumReagents(i) do
reagentItemLink = GetTradeSkillReagentItemLink(i,i2);
if (reagentItemLink ~= nil) then
for a,b,c,d in string.gfind(reagentItemLink, "(%d+):(%d+):(%d+):(%d+)") do
reagentItemLink = ""..a..":0:"..c..":0";
end
if (EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink] == nil) then
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink] = {};
end
EngBagsConfig[EngBags_PLAYERID]["tradeskill_items"][reagentItemLink][tradeskillName] = 1;
if ( (EngBank_BuildTradeList[tradeskillName] == nil) and (EngBagsConfig["build_trade_list"] == 1) ) then
EngBank_tt:SetTradeSkillItem(i,i2);
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink] = EngBags_ExtractTooltip("EngBank_tt");
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["n"],
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["t"],
EngBagsConfig[EngBags_PLAYERID]["trades"][tradeskillName][craftName][reagentItemLink]["c"] = GetTradeSkillReagentInfo(i,i2);
end
end
end
end
end
end
end
EngBank_BuildTradeList[tradeskillName] = 1; -- only do the exhaustive load once
end
end