Mercurial > wow > mailopener
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 78:bd80e4b4042f | 79:136aa3dd4dda |
|---|---|
| 461 | 461 |
| 462 return; | 462 return; |
| 463 elseif ((gold and gold > 0) or (items and items > 0)) then | 463 elseif ((gold and gold > 0) or (items and items > 0)) then |
| 464 -- Mail with some sort of attachments | 464 -- Mail with some sort of attachments |
| 465 | 465 |
| 466 local slotsAvailable = 0; | 466 local slotsAvailable; |
| 467 if self.db.profile.keepFreeSpace > 0 then | 467 if self.db.profile.keepFreeSpace > 0 then |
| 468 slotsAvailable = 0; | |
| 469 | |
| 470 -- First find out the amount of empty bag slots | |
| 468 for bag = 0, 4 do | 471 for bag = 0, 4 do |
| 469 local numberOfFreeSlots = GetContainerNumFreeSlots(bag); | 472 local numberOfFreeSlots, _ = GetContainerNumFreeSlots(bag); |
| 470 slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); | 473 slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); |
| 471 end | 474 end |
| 472 end | 475 |
| 473 | 476 -- Then calculate how much is available after the space we need to leave empty |
| 474 if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then | 477 slotsAvailable = ( slotsAvailable - self.db.profile.keepFreeSpace ); |
| 478 end | |
| 479 | |
| 480 -- and not MAIL_OPEN_EVERYTHING | |
| 481 -- Removed above part from below if statement, I forgot why I put it here and now it makes no sense | |
| 482 if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then | |
| 475 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then | 483 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then |
| 476 print(skippingString:format(index, subject, L["inventory is full"])); | 484 print(skippingString:format(index, subject, L["inventory is full"])); |
| 477 end | 485 end |
| 478 | 486 |
| 479 self:OpenNext(); | 487 self:OpenNext(); |
| 480 | 488 |
| 481 return; | 489 return; |
| 482 elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then | 490 elseif self.db.profile.keepFreeSpace > 0 and items and slotsAvailable ~= nil and slotsAvailable <= 0 then |
| 483 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then | 491 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then |
| 484 print(skippingString:format(index, subject, L["keep free space limit"])); | 492 print(skippingString:format(index, subject, L["keep free space limit"])); |
| 485 end | 493 end |
| 486 | 494 |
| 487 self:OpenNext(); | 495 self:OpenNext(); |
| 567 self:Debug("MO_OPENING_MAIL (#" .. index .. ")"); | 575 self:Debug("MO_OPENING_MAIL (#" .. index .. ")"); |
| 568 | 576 |
| 569 -- Notifiy other modules of opening | 577 -- Notifiy other modules of opening |
| 570 self:SendMessage("MO_OPENING_MAIL"); | 578 self:SendMessage("MO_OPENING_MAIL"); |
| 571 | 579 |
| 572 -- Open current mail | 580 if self.db.profile.keepFreeSpace > 0 and items > slotsAvailable then |
| 573 AutoLootMailItem(index); | 581 -- If this mail contains more items than the space available, we must only take a few attachments |
| 582 | |
| 583 for attachIndex = 1, ATTACHMENTS_MAX_RECEIVE do | |
| 584 if GetInboxItemLink(index, attachIndex) then | |
| 585 -- If this attachment actually exists | |
| 586 | |
| 587 if slotsAvailable > 0 then | |
| 588 -- If we still have slots available, then loot this one item | |
| 589 | |
| 590 self:Debug("Taking attachment " .. attachIndex); | |
| 591 | |
| 592 TakeInboxItem(index, attachIndex); | |
| 593 | |
| 594 -- Gained an item, lost an available slot | |
| 595 slotsAvailable = ( slotsAvailable - 1 ); | |
| 596 else | |
| 597 -- No more room available, announce and go to next item | |
| 598 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then | |
| 599 print(skippingString:format(index, subject, L["keep free space limit"])); | |
| 600 end | |
| 601 | |
| 602 -- We're done with this mail, it isn't empty so that event won't be triggered, but we may still continue | |
| 603 continue = true; | |
| 604 | |
| 605 self:OpenNext(); | |
| 606 | |
| 607 return; | |
| 608 end | |
| 609 end | |
| 610 end | |
| 611 else | |
| 612 -- Take everything from this mail | |
| 613 AutoLootMailItem(index); | |
| 614 end | |
| 574 | 615 |
| 575 if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then | 616 if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then |
| 576 if gold and gold > 0 then | 617 if gold and gold > 0 then |
| 577 print(L["Processing %d: %s (%s)"]:format(index, subject, MailOpener:FormatMoney(gold))); | 618 print(L["Processing %d: %s (%s)"]:format(index, subject, MailOpener:FormatMoney(gold))); |
| 578 else | 619 else |
| 919 name = L["Keep Free Space"], | 960 name = L["Keep Free Space"], |
| 920 args = { | 961 args = { |
| 921 description = { | 962 description = { |
| 922 order = 10, | 963 order = 10, |
| 923 type = "description", | 964 type = "description", |
| 924 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."], | 965 name = L["You can set an amount of bag space you wish to reserve when opening mail."], |
| 925 }, | 966 }, |
| 926 header = { | 967 header = { |
| 927 order = 15, | 968 order = 15, |
| 928 type = "header", | 969 type = "header", |
| 929 name = "", | 970 name = "", |
| 934 min = 0, | 975 min = 0, |
| 935 max = 100, | 976 max = 100, |
| 936 step = 1, | 977 step = 1, |
| 937 width = "double", | 978 width = "double", |
| 938 name = L["Keep free space"], | 979 name = L["Keep free space"], |
| 939 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."], | 980 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."], |
| 940 set = function(i, v) self.db.profile.keepFreeSpace = v; end, | 981 set = function(i, v) self.db.profile.keepFreeSpace = v; end, |
| 941 get = function() return self.db.profile.keepFreeSpace; end, | 982 get = function() return self.db.profile.keepFreeSpace; end, |
| 942 }, | 983 }, |
| 943 }, | 984 }, |
| 944 }, | 985 }, |
