Mercurial > wow > mailopener
diff Modules/OpenAll.lua @ 79:136aa3dd4dda
The keep free space will now cause the opener to partially loot mail when you are near the keep free space requirement, rather than skipping the entire mail. The config has been changed to reflect this.
| author | Zerotorescue |
|---|---|
| date | Thu, 16 Sep 2010 17:20:34 +0200 |
| parents | eadff31e61e8 |
| children | b3b9220c91e6 |
line wrap: on
line diff
--- a/Modules/OpenAll.lua Thu Sep 16 16:21:30 2010 +0200 +++ b/Modules/OpenAll.lua Thu Sep 16 17:20:34 2010 +0200 @@ -463,15 +463,23 @@ elseif ((gold and gold > 0) or (items and items > 0)) then -- Mail with some sort of attachments - local slotsAvailable = 0; + local slotsAvailable; if self.db.profile.keepFreeSpace > 0 then + slotsAvailable = 0; + + -- First find out the amount of empty bag slots for bag = 0, 4 do - local numberOfFreeSlots = GetContainerNumFreeSlots(bag); + local numberOfFreeSlots, _ = GetContainerNumFreeSlots(bag); slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); end + + -- Then calculate how much is available after the space we need to leave empty + slotsAvailable = ( slotsAvailable - self.db.profile.keepFreeSpace ); end - if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then + -- and not MAIL_OPEN_EVERYTHING + -- Removed above part from below if statement, I forgot why I put it here and now it makes no sense + if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then print(skippingString:format(index, subject, L["inventory is full"])); end @@ -479,7 +487,7 @@ self:OpenNext(); return; - elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then + elseif self.db.profile.keepFreeSpace > 0 and items and slotsAvailable ~= nil and slotsAvailable <= 0 then if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then print(skippingString:format(index, subject, L["keep free space limit"])); end @@ -569,8 +577,41 @@ -- Notifiy other modules of opening self:SendMessage("MO_OPENING_MAIL"); - -- Open current mail - AutoLootMailItem(index); + if self.db.profile.keepFreeSpace > 0 and items > slotsAvailable then + -- If this mail contains more items than the space available, we must only take a few attachments + + for attachIndex = 1, ATTACHMENTS_MAX_RECEIVE do + if GetInboxItemLink(index, attachIndex) then + -- If this attachment actually exists + + if slotsAvailable > 0 then + -- If we still have slots available, then loot this one item + + self:Debug("Taking attachment " .. attachIndex); + + TakeInboxItem(index, attachIndex); + + -- Gained an item, lost an available slot + slotsAvailable = ( slotsAvailable - 1 ); + else + -- No more room available, announce and go to next item + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then + print(skippingString:format(index, subject, L["keep free space limit"])); + end + + -- We're done with this mail, it isn't empty so that event won't be triggered, but we may still continue + continue = true; + + self:OpenNext(); + + return; + end + end + end + else + -- Take everything from this mail + AutoLootMailItem(index); + end if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then if gold and gold > 0 then @@ -921,7 +962,7 @@ description = { order = 10, type = "description", - name = L["You can set an amount of bag space you wish to reserve when opening mail. Mail with a higher amount of attachments than available space will be skipped completely with this option set above 0."], + name = L["You can set an amount of bag space you wish to reserve when opening mail."], }, header = { order = 15, @@ -936,7 +977,7 @@ step = 1, width = "double", name = L["Keep free space"], - desc = L["Change the amount of space to reserve for other things when opening mail. If this option is set higher than 0, mail with a higher amount of attachments than available space will be skipped completely.\n\nE.g. If this is set to 1 and you have a total of 12 slots left then any mail with 12 attachments will be skipped while one with 11 attachments would be opened."], + desc = L["Change the amount of space to reserve for other things when opening mail.\n\nEnabling this functionality by setting this value above 0 may increase resource usage slightly."], set = function(i, v) self.db.profile.keepFreeSpace = v; end, get = function() return self.db.profile.keepFreeSpace; end, },
