iFedix / Dustman

An Elder Scrolls Online addon
Other
6 stars 3 forks source link

Sell Fence items by Quantity (after Quality-sort) #7

Open mihawk90 opened 4 months ago

mihawk90 commented 4 months ago

This implements a new function which not only sorts by Quality, but also by Quantity in each individual stack. This is useful for Vendors with limited transactions (i.e. Fences), and can be used to sell both the highest quality goods (which is already the case), as well as freeing as many bag slots as possible by prioritising smaller stacks in the inventory. Dustman already handles selling parts of larger stacks so "leftover" stacks are not a concern.


If you have any pointers on how this may be achieved more elegantly/efficiently, I'll be happy to work on this more. I'm just not very experienced in LUA (I dabbled back in the WoW days but that was 10 years ago...), but from preliminary testing it seems to work just fine.

I'm putting this in Draft until I had some time to actually test in game (I wrote this overnight when my Fence limit was already reached), but from the debug dumps I was logging it seems to all be working as expected.

Although this should be working just fine with any vendor, I deliberately implemented a new function so as to not interfere with other functionality I may not be aware of, and only adopted it for selling at a fence.


edit: One day and a full bag of stolen goods later...

[05:15:29] uespLog v3.23 add-on initialized...debug output is currently off. Epics: [05:16:05] Dustman sold 1x [Harald Hand-Free's Stein] for 2025. [05:16:05] Dustman sold 1x [Ninth Legion Commander's Seal] for 2025. [05:16:05] Dustman sold 1x [Longhouse Gold Quill Pen] for 2025. [05:16:05] Dustman sold 1x [Bottle, Liquor] for 135. Superiors: [05:16:05] Dustman sold 1x [Cyrodiil Service Medal] for 338. [05:16:05] Dustman sold 1x [Queen Mabjaarn's Risque Etching] for 338. [05:16:05] Dustman sold 1x [Mudcrab-Chitin Rotmeth Pitcher] for 338. [05:16:05] Dustman sold 1x [Jeweled Kaleidoscope] for 338. [05:16:05] Dustman sold 1x [First Edition Fjokki] for 338. [05:16:05] Dustman sold 1x [Wooden Serpent Totem] for 338. [05:16:05] Dustman sold 1x [Bottle of Torchbug Ink] for 338. [05:16:05] Dustman sold 1x [Kwama Cuttle Earplugs] for 338. [05:16:05] Dustman sold 1x [Ayleid Paperweight] for 338. [05:16:05] Dustman sold 1x [Wamasu Organ Lantern] for 338. [05:16:05] Dustman sold 1x [Illicit Letters from Daggerfall] for 338. [05:16:05] Dustman sold 1x [Warrior Wave] for 338. [05:16:05] Dustman sold 1x ["Deceiver's Dice" Game] for 338. [05:16:05] Dustman sold 1x [Bolt of Iridescent Spidersilk] for 338. [05:16:05] Dustman sold 1x [Fusozay Cushion] for 338. [05:16:05] Dustman sold 1x [Dunmeri Throw Rug] for 338. [05:16:05] Dustman sold 1x [Skald-King's Sonnet] for 338. [05:16:05] Dustman sold 1x [Mummified Hand] for 338. [05:16:05] Dustman sold 1x [Lion Guard Meal Kit] for 338. [05:16:05] Dustman sold 1x [Horrified Flesh-Mask] for 338. [05:16:05] Dustman sold 1x [Silver Serving Platter] for 338. [05:16:05] Dustman sold 1x [Ancient Brass Sackbut] for 338. [05:16:05] Dustman sold 1x [Thulvald's Ebony Log Splitter] for 338. [05:16:05] Dustman sold 1x [Nilata Crystal Shard] for 338. [05:16:05] Dustman sold 1x ["Traitor's Tor" Game] for 338. [05:16:05] Dustman sold 1x [Baandari Stoneware Bowl Calendar] for 338. [05:16:05] Dustman sold 1x [Crafter's Ruler] for 338. [05:16:05] Dustman sold 1x [Alik'r Spice Decanters] for 338. [05:16:05] Dustman sold 1x [Orichalcum Mystery Sphere] for 338. [05:16:05] Dustman sold 1x [Bizarre Daedric Text] for 338. [05:16:05] Dustman sold 1x [Ink of a Different Color] for 338. [05:16:05] Dustman sold 2x [Sabre-Skin Caddy Sack] for 676. [05:16:05] Dustman sold 2x [Savage Werewolf Marionette] for 676. [05:16:05] Dustman sold 2x [Precious Kynesgrove Prayer Beads] for 676. [05:16:05] Dustman sold 2x [Nord Clan Neckerchief] for 676. [05:16:05] Dustman sold 2x [Etched Troll Tooth] for 676. [05:16:05] Dustman sold 2x [Konunleikar Bookmark Keepsake] for 676. [05:16:05] Dustman sold 2x [Nocturnal Nord Hair Net] for 676. [05:16:05] Dustman sold 2x [Sword-Singer's Finger-Weights] for 676. [05:16:05] Dustman sold 2x [Silver Sandal Spikes] for 676. [05:16:05] Dustman sold 2x [Haunted Wood Candlestick] for 676. [05:16:05] Dustman sold 3x [Porcelain Stew Bowl] for 1014. [05:16:05] Dustman sold 3x [Windhelm Salad Tongs] for 1014. [05:16:05] Dustman sold 3x [Pinewood Nibble Bowl] for 1014. [05:16:05] Dustman sold 3x [Buca's Tasty Tooth Polish] for 1014. [05:16:05] Dustman sold 3x [Feast of Dibella Centerpiece] for 1014. [05:16:05] Due to ZOS restrictions, Dustman processed only 50 transactions. Please wait 10 seconds, and interact again with npc. [05:16:05] Dustman sold 70 items (50 stacks) for 28518. [05:18:21] Dustman sold 3x [Piece of the Palace of Ysgramor] for 1014. [05:18:21] Dustman sold 3x [Kindlepitch Pouch] for 1014. [05:18:21] Dustman sold 4x [Mara's Floral Star Vase] for 1352. [05:18:21] Dustman sold 4x [Fancy Skald-King Tablecloth] for 1352. [05:18:21] Dustman sold 4x [Temple Location Talisman] for 1352. [05:18:21] Dustman sold 5x [Royal Banner of Evermore] for 1690. [05:18:21] Dustman sold 5x [Cyrodiil Service Medal] for 1690. [05:18:21] Dustman sold 5x [Precious Kynesgrove Prayer Beads] for 1690. Fines: [05:18:21] Dustman sold 1x [Silver Tea Tray] for 135. [05:18:21] Dustman sold 1x [Wooden Drinking Goblet] for 135. [05:18:21] Dustman sold 1x [Rare Owl-Feather Quill] for 135. [05:18:21] Dustman sold 1x [Nightwood Ice Staff] for 394. [05:18:21] Dustman sold 1x [Long-Handled Mudcrab Flipper] for 135. [05:18:21] Dustman sold 1x [Frost Troll Ragamuffin Doll] for 135. [05:18:21] Dustman sold 1x [Risque Boudoir Portrait] for 135. [05:18:21] Dustman sold 1x [Silk Rope] for 135. [05:18:21] Dustman sold 1x [Meat Strip Drying Rack] for 135. [05:18:21] Dustman sold 1x [Orcish Longevity Candle] for 135. [05:18:21] Dustman sold 1x [Torn Covenant Rank Insignia] for 135. [05:18:21] Dustman sold 1x [Xeech'ki Doll] for 135. [05:18:21] Dustman sold 1x [Poorly Groomed False Teeth] for 135. [05:18:21] Dustman sold 1x [You-Know-What Distiller] for 135. [05:18:21] Dustman sold 1x [Majolrun's Warming Bath Stones] for 135. [05:18:21] Dustman sold 1x [Ornamental War Horn] for 135. [05:18:21] Dustman sold 1x [Torn Dominion Rank Insignia] for 135. [05:18:21] Dustman sold 1x [Soldier's Shaving Mirror] for 135. [05:18:21] Dustman sold 1x [Konunleikar Festival Basket] for 135. [05:18:21] Dustman sold 1x [Daggerfall Covenant Correspondence Sheets] for 135. [05:18:21] Dustman sold 1x [Sabre Cat Walking Stick] for 135. [05:18:21] Dustman sold 1x [Polished Leather Scroll Case] for 135. [05:18:21] Dustman sold 1x [Pranks & Pleasures Card Game] for 135. [05:18:21] Dustman sold 1x [Wool-Filled Pillow] for 135. [05:18:21] Dustman sold 1x [Silver Serviette Holder] for 135. [05:18:21] Dustman sold 1x [Silver Etched Cake Platter] for 135. [05:18:21] Dustman sold 1x [Silver Gravy Boat] for 135. [05:18:21] Dustman sold 1x [Nord Battle Wraps] for 135. [05:18:21] Dustman sold 1x [Woven Blanket] for 135. [05:18:21] Dustman sold 1x [Whittled Cat Head] for 135. [05:18:21] Dustman sold 1x [Stamped Silver Pitcher] for 135. [05:18:21] Dustman sold 2x [Nord House God] for 270. [05:18:21] Dustman sold 2x [Phial of Lamp Oil] for 270. [05:18:21] Dustman sold 2x [Polished Wooden Spoon] for 270. [05:18:21] Dustman sold 2x [Jarl's Best Sleeve Pin] for 270. [05:18:21] Dustman sold 2x [Thunderbug-Shell Pipe] for 270. [05:18:21] Dustman sold 2x [Wolf Pelt Sleeping Bag] for 270. [05:18:21] Dustman sold 2x [Dwemer Grocery List] for 270. [05:18:21] Dustman sold 2x [Souvenir Imperial Heater] for 270. [05:18:21] Dustman sold 2x [Stuffed Rat Carcass] for 270. [05:18:21] Dustman sold 2x [Wooden Building Blocks] for 270. [05:18:21] Dustman sold 2x [Gold Tassels] for 270. [05:18:21] Due to ZOS restrictions, Dustman processed only 50 transactions. Please wait 10 seconds, and interact again with npc. [05:18:21] Dustman sold 86 items (50 stacks) for 18568.

I'd say it works pretty well :)

mihawk90 commented 4 months ago

Used this for a couple days now and didn't run into any issues.

mihawk90 commented 4 months ago

Hm so I have used this for a week with no issues, even yesterday, and suddenly today I am getting an error that makes no sense to me...

bad argument #1 to 'table.insert' (table/struct expected, got nil)
stack traceback:
[C]: in function 'table.insert'
user:/AddOns/Dustman/Dustman.lua:554: in function 'pairsByQualityAndQuantity'
user:/AddOns/Dustman/Dustman.lua:594: in function 'SellJunkItems'
user:/AddOns/Dustman/Dustman.lua:1802: in function 'm_callback'
/EsoUI/Libraries/ZO_Dialog/ZO_Dialog.lua:120: in function 'HandleCallback'
/EsoUI/Libraries/ZO_KeybindButton/ZO_KeybindButton.lua:215: in function 'ZO_KeybindButtonMixin:OnClicked'
/EsoUI/Libraries/ZO_Dialog/ZO_Dialog.lua:1238: in function 'ZO_Dialogs_HandleButtonForKeybind'
/EsoUI/Libraries/ZO_Dialog/ZO_Dialog.lua:1250: in function 'ZO_Dialogs_ButtonKeybindPressed'
:1: in function '(main chunk)'
554     table.insert(arrayQuality[data.quality], data)

But the arrayQuality sub-arrays are getting initialised just above:

    for i = 1, 5 do
        arrayQuality[i] = {}
    end

So I don't know how that can be nil...

edit: Fixed below, that's what happens when you usually delete all Trash items and don't for once :sweat_smile: