comparison Queue.lua @ 17:8f5c02113c5c

Reduced the softmax of most ranges from 1.000 to 100. This should make them actually useful. You can still manually enter an amount below the sliders of up to 100.000. The help text for the ?Replenishing stock? category now includes bonus queue information. Added an option to the ?add items? tab called ?Import premade data? which allows a user to import item data from a premade group shipped with the addon. If this premade data ever changes, the user will be notified and queried for an update. Added a ?mass remove? option to the ?current items? tab. Item data should be imported again when importing a complete group. Added ?DataStore (current account only)?, ?DataStore (with guilds)? and ?DataStore (without guilds)? item count options. One might prefer these over Altoholic for a few reasons. Scroll IDs are now stored in a seperate file in a new ?data? folder. Premade groups data can be found there too. Bonus queue and min crafting queue options should now be fully functional. Enchanting scrolls should now work properly. Text in the summary of the value of items below the price threshold window will now be colored completely grey.
author Zerotorescue
date Wed, 20 Oct 2010 01:30:51 +0200
parents 0fc8a54516d7
children 7d7aaa3fbe94
comparison
equal deleted inserted replaced
16:68958c55c43d 17:8f5c02113c5c
1 local addon = LibStub("AceAddon-3.0"):GetAddon("Inventorium"); 1 local addon = select(2, ...);
2 local mod = addon:NewModule("Queue", "AceEvent-3.0", "AceTimer-3.0"); 2 local mod = addon:NewModule("Queue", "AceEvent-3.0", "AceTimer-3.0");
3
4 local scrollIds = {
5 [27951] = 37603,
6 [7418] = 38679,
7 [7420] = 38766,
8 [7426] = 38767,
9 [7428] = 38768,
10 [7443] = 38769,
11 [7454] = 38770,
12 [7457] = 38771,
13 [7745] = 38772,
14 [7748] = 38773,
15 [7766] = 38774,
16 [7771] = 38775,
17 [7776] = 38776,
18 [7779] = 38777,
19 [7782] = 38778,
20 [7786] = 38779,
21 [7788] = 38780,
22 [7793] = 38781,
23 [7857] = 38782,
24 [7859] = 38783,
25 [7861] = 38784,
26 [7863] = 38785,
27 [7867] = 38786,
28 [13378] = 38787,
29 [13380] = 38788,
30 [13419] = 38789,
31 [13421] = 38790,
32 [13464] = 38791,
33 [13485] = 38792,
34 [13501] = 38793,
35 [13503] = 38794,
36 [13522] = 38795,
37 [13529] = 38796,
38 [13536] = 38797,
39 [13538] = 38798,
40 [13607] = 38799,
41 [13612] = 38800,
42 [13617] = 38801,
43 [13620] = 38802,
44 [13622] = 38803,
45 [13626] = 38804,
46 [13631] = 38805,
47 [13635] = 38806,
48 [13637] = 38807,
49 [13640] = 38808,
50 [13642] = 38809,
51 [13644] = 38810,
52 [13646] = 38811,
53 [13648] = 38812,
54 [13653] = 38813,
55 [13655] = 38814,
56 [13657] = 38815,
57 [13659] = 38816,
58 [13661] = 38817,
59 [13663] = 38818,
60 [13687] = 38819,
61 [13689] = 38820,
62 [13693] = 38821,
63 [13695] = 38822,
64 [13698] = 38823,
65 [13700] = 38824,
66 [13746] = 38825,
67 [13794] = 38826,
68 [13815] = 38827,
69 [13817] = 38828,
70 [13822] = 38829,
71 [13836] = 38830,
72 [13841] = 38831,
73 [13846] = 38832,
74 [13858] = 38833,
75 [13868] = 38834,
76 [13882] = 38835,
77 [13887] = 38836,
78 [13890] = 38837,
79 [13898] = 38838,
80 [13905] = 38839,
81 [13915] = 38840,
82 [13917] = 38841,
83 [13931] = 38842,
84 [13933] = 38843,
85 [13935] = 38844,
86 [13937] = 38845,
87 [13939] = 38846,
88 [13941] = 38847,
89 [13943] = 38848,
90 [13945] = 38849,
91 [13947] = 38850,
92 [13948] = 38851,
93 [20008] = 38852,
94 [20009] = 38853,
95 [20010] = 38854,
96 [20011] = 38855,
97 [20012] = 38856,
98 [20013] = 38857,
99 [20014] = 38858,
100 [20015] = 38859,
101 [20016] = 38860,
102 [20017] = 38861,
103 [20020] = 38862,
104 [20023] = 38863,
105 [20024] = 38864,
106 [20025] = 38865,
107 [20026] = 38866,
108 [20028] = 38867,
109 [20029] = 38868,
110 [20030] = 38869,
111 [20031] = 38870,
112 [20032] = 38871,
113 [20033] = 38872,
114 [20034] = 38873,
115 [20035] = 38874,
116 [20036] = 38875,
117 [21931] = 38876,
118 [22749] = 38877,
119 [22750] = 38878,
120 [23799] = 38879,
121 [23800] = 38880,
122 [23801] = 38881,
123 [23802] = 38882,
124 [23803] = 38883,
125 [23804] = 38884,
126 [25072] = 38885,
127 [25073] = 38886,
128 [25074] = 38887,
129 [25078] = 38888,
130 [25079] = 38889,
131 [25080] = 38890,
132 [25081] = 38891,
133 [25082] = 38892,
134 [25083] = 38893,
135 [25084] = 38894,
136 [25086] = 38895,
137 [27837] = 38896,
138 [27899] = 38897,
139 [27905] = 38898,
140 [27906] = 38899,
141 [27911] = 38900,
142 [27913] = 38901,
143 [27914] = 38902,
144 [27917] = 38903,
145 [27944] = 38904,
146 [27945] = 38905,
147 [27946] = 38906,
148 [27947] = 38907,
149 [27948] = 38908,
150 [27950] = 38909,
151 [27954] = 38910,
152 [27957] = 38911,
153 [27958] = 38912,
154 [27960] = 38913,
155 [27961] = 38914,
156 [27962] = 38915,
157 [27967] = 38917,
158 [27968] = 38918,
159 [27971] = 38919,
160 [27972] = 38920,
161 [27975] = 38921,
162 [27977] = 38922,
163 [27981] = 38923,
164 [27982] = 38924,
165 [27984] = 38925,
166 [28003] = 38926,
167 [28004] = 38927,
168 [33990] = 38928,
169 [33991] = 38929,
170 [33992] = 38930,
171 [33993] = 38931,
172 [33994] = 38932,
173 [33995] = 38933,
174 [33996] = 38934,
175 [33997] = 38935,
176 [33999] = 38936,
177 [34001] = 38937,
178 [34002] = 38938,
179 [34003] = 38939,
180 [34004] = 38940,
181 [34005] = 38941,
182 [34006] = 38942,
183 [34007] = 38943,
184 [34008] = 38944,
185 [34009] = 38945,
186 [34010] = 38946,
187 [42620] = 38947,
188 [42974] = 38948,
189 [44383] = 38949,
190 [44483] = 38950,
191 [44484] = 38951,
192 [44488] = 38953,
193 [44489] = 38954,
194 [44492] = 38955,
195 [44494] = 38956,
196 [44500] = 38959,
197 [44506] = 38960,
198 [44508] = 38961,
199 [44509] = 38962,
200 [44510] = 38963,
201 [44513] = 38964,
202 [44524] = 38965,
203 [44528] = 38966,
204 [44529] = 38967,
205 [44555] = 38968,
206 [44556] = 38969,
207 [60616] = 38971,
208 [44576] = 38972,
209 [44582] = 38973,
210 [44584] = 38974,
211 [44588] = 38975,
212 [44589] = 38976,
213 [44590] = 38977,
214 [44591] = 38978,
215 [44592] = 38979,
216 [44593] = 38980,
217 [44595] = 38981,
218 [44596] = 38982,
219 [44598] = 38984,
220 [60623] = 38986,
221 [44616] = 38987,
222 [44621] = 38988,
223 [44623] = 38989,
224 [44625] = 38990,
225 [44629] = 38991,
226 [44630] = 38992,
227 [44631] = 38993,
228 [44633] = 38995,
229 [44635] = 38997,
230 [46578] = 38998,
231 [46594] = 38999,
232 [47051] = 39000,
233 [47672] = 39001,
234 [47766] = 39002,
235 [47898] = 39003,
236 [47899] = 39004,
237 [47900] = 39005,
238 [47901] = 39006,
239 [59625] = 43987,
240 [60606] = 44449,
241 [60621] = 44453,
242 [60653] = 44455,
243 [60609] = 44456,
244 [60663] = 44457,
245 [60668] = 44458,
246 [60691] = 44463,
247 [60692] = 44465,
248 [60707] = 44466,
249 [60714] = 44467,
250 [60763] = 44469,
251 [60767] = 44470,
252 [59621] = 44493,
253 [59619] = 44497,
254 [44575] = 44815,
255 [62256] = 44947,
256 [62948] = 45056,
257 [62959] = 45060,
258 [63746] = 45628,
259 [64441] = 46026,
260 [64579] = 46098,
261 [71692] = 50816,
262 };--enchantId=scrollId
263 3
264 function mod:OnEnable() 4 function mod:OnEnable()
265 -- Register our own slash commands 5 -- Register our own slash commands
266 addon:RegisterSlash(function() 6 addon:RegisterSlash(function()
267 self:QueueAll(); 7 self:QueueAll();
307 end 47 end
308 48
309 for itemId, _ in pairs(addon.db.global.groups[groupName].items) do 49 for itemId, _ in pairs(addon.db.global.groups[groupName].items) do
310 if not temp[itemId] then 50 if not temp[itemId] then
311 local itemLink = select(2, GetItemInfo(itemId)); 51 local itemLink = select(2, GetItemInfo(itemId));
312 print("Couldn't queue " .. itemLink); 52 print("Couldn't queue " .. itemLink .. " (not part of this profession)");
313 end 53 end
314 end 54 end
315 end 55 end
316 56
317 function mod:ProcessTradeSkill(i, groupName, temp) 57 function mod:ProcessTradeSkill(i, groupName, temp)
322 local itemId = addon:GetItemId(itemLink); 62 local itemId = addon:GetItemId(itemLink);
323 if not itemId then 63 if not itemId then
324 -- If this isn't an item, it can only be an enchant instead 64 -- If this isn't an item, it can only be an enchant instead
325 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h")); 65 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h"));
326 66
327 itemId = scrollIds[itemId]; -- change enchantIds into scrollIds 67 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds
328 end 68 end
329 69
330 if addon.db.global.groups[groupName].items[itemId] then 70 if addon.db.global.groups[groupName].items[itemId] then
331 -- This item is in this group, queue it! 71 -- This item is in this group, queue it!
332 72
336 end 76 end
337 77
338 local currentStock = addon:GetItemCount(itemId); 78 local currentStock = addon:GetItemCount(itemId);
339 if currentStock >= 0 then 79 if currentStock >= 0 then
340 -- Current stock will be -1 when no itemcount addon was found 80 -- Current stock will be -1 when no itemcount addon was found
341 local amount = ( addon:GetOptionByKey(groupName, "restockTarget") - currentStock ); 81 local restockTarget = addon:GetOptionByKey(groupName, "restockTarget");
82 local bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue");
83 local minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * restockTarget );
342 84
343 if amount > 0 then 85 local amount = ( restockTarget - currentStock );
86
87 if currentStock == 0 and bonusQueue > 0 then
88 amount = floor( ( amount * ( bonusQueue + 1 ) ) + .5 ); -- round
89 end
90
91 if amount > 0 and amount >= minCraftingQueue then
344 self:Queue(i, amount); 92 self:Queue(i, amount);
345 93
346 print("Queued " .. amount .. " of " .. itemLink); 94 print("Queued " .. amount .. " of " .. itemLink);
347 end 95 end
348 else 96 else