TheGeneticsGuy / Mass_Salvage_Assist

Assist in Mass Salvaging Reagents uniterrupted
2 stars 0 forks source link

[Request] Allow addon to work when called from other sources and not rely on UI #2

Open ninthwalker opened 13 hours ago

ninthwalker commented 13 hours ago

Currently, you get info from the professions UI for various functions. I craft via macro's a lot, and some of them do not need to open or have the pofessions UI open. This is also useful due to crafting window memory leak that I don't think has been fixed yet by Blizzard. So having the crafting window closed helps when doing mass crafting like this addon is designed for.

It would be nice if you could get the info needed via other api calls or check if the profession window is not open, to then fall back to a different api since the macro will not 'load' the mat into the crafting interface.

Example: This will fail if not loaded via crafting window: ProfessionsFrame.CraftingPage.SchematicForm:GetTransaction().salvageItem; https://github.com/TheGeneticsGuy/Mass_Salvage_Assist/blob/main/MSA_Crafting.lua#L189

Instead, maybe check if that 'item.debugItemID' is nil, fall back on getting the current craft id via a different api or something, and if that is also still nil, print error that item can not be identified instead of a LUA error. ``

Thanks for your addon!

Edit: So i poked around a little and i'm not sure if it's possible, but figured I would toss it to you to see if you knew. Checked a couple api calls, and wasn't able to see the material being converted, only the spell that was doing it. Have a workaround idea for that, but don't think it would be worth adding for people like me. My workaround idea was to get all mats that are valid for the current crafting operation, save the count, check those counts again after one cast, and whatever mat went down was the one being used. lol =/

Sirius5783 commented 10 hours ago

I have a macro that can do mass crafting as a button to press, but it has the stack problem which this addon have solved. I used to press another button with a packing bag marco each time first. The macro code is below, maybe you guys could find something useful from there. /use item:211802 /run for bg=0,5 do for s=1,C_Container.GetContainerNumSlots(bg) do local lnk=ItemLocation:CreateFromBagAndSlot(bg,s) if lnk:IsValid() and C_Item.GetItemID(lnk) == 211802 then C_TradeSkillUI.CraftSalvage(430315,1000,lnk) return end end end

TheGeneticsGuy commented 10 hours ago

So, I was unaware of the profession window memory leak - someone just reported to me that my addon was taking up like 5GB of addon memory after a few hours of nonstop crafting - I was like wuh!? I couldn't figure out as to why as I didn't see myself introducing any kind of crazy memory leak like that lol...

This is really good to know though. In terms of getting IDs, I can probably work something out to this, I just went the easy way.

However, mass crafting even with profession window closed? This is the first I've heard of this... I'll tinker around and see what I find regarding this. Thanks for the heads up on all of this. I like the idea of not having to rely on the source. I will say, that's definitely appealing. I find that the profession window, if I am doing ultra fast speed milling when in a capital city can get REALLY slow with profession window open. I have to leave the city. I wonder if it would be effective without.

TheGeneticsGuy commented 8 hours ago

So I think I have some good news for you guys... but I want to test a little more so standby lol

TheGeneticsGuy commented 6 hours ago

Ok, so let me tell you my strategy on getting the item_id, since you are right, there doesn't seem to be any API to obtain it when window isn't open, and I dug everywhere. I even went into the Blizz InterfaceCode to dig through Blizz's own code to find something... nothing.

Ok, so if I can't do it that way instead, what I do is see the /etrace and see if I can find a pattern, which is exactly what I did. I know what the casting spell is of the profession, so when the event fires "TRADE_SKILL_CRAFT_BEGIN" and it matches my salvaging spell, I know that the next time the event "ITEM_COUNT_CHANGED" fires, it is going to be the reagent used in the craft, as the reagent is used BEFORE you loot the newly crafted item. This event shows the item number. I store that number for access globally and when it comes to combining stacks again, I know which item I am salvaging and what to combine again. No need to create complicated tables.

Anyway, I have it pretty well tested but I am going to tinker around a little more. But yes, I have it fully working WITHOUT the profession window now. I kind of am curious about expanding the use of macros for people, but that just opens up another whole can of worms... I might just leave it as a nice feature for the few "in-the-know" until I decide what to do...

ninthwalker commented 3 hours ago

Nice. I also was looking through etrace but didn't think to check the order it fired off those events since they were so close to each other. Would be cool if it can detect it that way. I use a WA i made that cycles through all the Thaumaturgy mats of choosing so it can be done with just one button and it loads via mixin (similar to the macro @Sirius5783 posted) so does not need the UI. I was catching the crafting ending event, and having the bags resstack so it would auto fix the stacking issue. Your way of re-stacking during the crafting is better though.

The WA code for ref and some of my notes I was using for it. Utilizes re-keybinding of macro functionality and things like that. Specific for Thaumaturgy, but if you ever did want some ideas for future integration could take a look. I could see some kind of auto-keybind attaching to whatever the current craft is being useful or something down the line. wow_thaumaturgy

Thanks for looking in to it.

Edit: Looked at etrace again after your suggestion, maybe you are able to grab correct order or maybe etrace's GUI doesn't show the real order that code would get. Here's a sample of what i see, and in this case the material being used was Mycobloom R2, but it show's last in etrace for ITEM_COUNT_CHANGED (210797)

image

Edit2: I take it back, it is just a graphical etrace thing it looks like. When i grabbed the event in code, the mat used is returned first every time. Nice find. image

TheGeneticsGuy commented 3 hours ago

Ya, I have a couple other tricks up my sleeve lol - I think I am going to drop something you'll appreciate but it's going to have to be tomorrow, just not enough time tonight to finish.