Mercurial > wow > inventory
comparison Modules/Scanner.lua @ 123:ee4672f21586
Restocking from a merchant now considers bonus queue and min crafting queue settings.
author | Zerotorescue |
---|---|
date | Sun, 16 Jan 2011 00:41:02 +0100 |
parents | 6724bc8eface |
children | 8460855e3d90 |
comparison
equal
deleted
inserted
replaced
122:6724bc8eface | 123:ee4672f21586 |
---|---|
340 -- Go through all groups | 340 -- Go through all groups |
341 for groupName, values in pairs(addon.db.profile.groups) do | 341 for groupName, values in pairs(addon.db.profile.groups) do |
342 -- Settings | 342 -- Settings |
343 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); | 343 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); |
344 local localItemData = addon:GetOptionByKey(groupName, "localItemData"); | 344 local localItemData = addon:GetOptionByKey(groupName, "localItemData"); |
345 local isRefillEnabled = addon:GetOptionByKey(groupName, "autoRefill"); | 345 local requiredItems, bonusQueue, minCraftingQueue, isRefillEnabled; |
346 local requiredItems = ((isRestock and addon:GetOptionByKey(groupName, "restockTarget")) or addon:GetOptionByKey(groupName, "minLocalStock")); | 346 if isRestock then |
347 requiredItems = addon:GetOptionByKey(groupName, "restockTarget"); | |
348 bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue"); | |
349 minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * requiredItems ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3 | |
350 else | |
351 isRefillEnabled = addon:GetOptionByKey(groupName, "autoRefill"); | |
352 requiredItems = addon:GetOptionByKey(groupName, "minLocalStock"); | |
353 end | |
347 | 354 |
348 local isTracked = (trackAt and trackAt[playerName]); -- Is this character interested in this data? | 355 local isTracked = (trackAt and trackAt[playerName]); -- Is this character interested in this data? |
349 local isConsideredLocal = (localItemData and localItemData[location]); -- if this location was checked as local storage, don't refill from it | 356 local isConsideredLocal = (localItemData and localItemData[location]); -- if this location was checked as local storage, don't refill from it |
350 | 357 |
351 if values.items and isTracked and (isRefillEnabled or isRestock) and not isConsideredLocal then | 358 if values.items and isTracked and (isRestock or isRefillEnabled) and not isConsideredLocal then |
352 addon:Debug("Scanning |cff00ff00%s|r", groupName); | 359 addon:Debug("Scanning |cff00ff00%s|r", groupName); |
353 | 360 |
354 for itemId, _ in pairs(values.items) do | 361 for itemId, _ in pairs(values.items) do |
355 -- Find this item in the source | 362 -- Find this item in the source |
356 local containerItem = itemCache[itemId]; | 363 local containerItem = itemCache[itemId]; |
362 local currentItemCount = ((isRestock and addon:GetItemCount(itemId, groupName)) or addon:GetLocalItemCount(itemId, groupName)); | 369 local currentItemCount = ((isRestock and addon:GetItemCount(itemId, groupName)) or addon:GetLocalItemCount(itemId, groupName)); |
363 | 370 |
364 -- Check if we have enough items local (but only do so if this location also has enough available) | 371 -- Check if we have enough items local (but only do so if this location also has enough available) |
365 local missingItems = (requiredItems - currentItemCount); | 372 local missingItems = (requiredItems - currentItemCount); |
366 | 373 |
367 if missingItems > 0 then | 374 if isRestock and currentItemCount == 0 and bonusQueue and bonusQueue > 0 then |
375 -- If we have none left and the bonus queue is enabled, modify the amount to be queued | |
376 | |
377 missingItems = floor( ( missingItems * ( bonusQueue + 1 ) ) + .5 ); -- round | |
378 end | |
379 | |
380 if missingItems > 0 and (not isRestock or missingItems >= minCraftingQueue) then | |
368 -- Check how many are available | 381 -- Check how many are available |
369 local availableItems = ((containerItem.totalCount) or 0); | 382 local availableItems = ((containerItem.totalCount) or 0); |
370 -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) | 383 -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) |
371 -- -1 available items indicates unlimited amount, in that case we must cap at missing items | 384 -- -1 available items indicates unlimited amount, in that case we must cap at missing items |
372 local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems); | 385 local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems); |