The following kind of "Post HooK" code, which is used in some addons which got to do with crafting...
currently makes the PickupInventoryItem code insecure...
Code:
EsoUI/Ingame/Inventory/InventorySlot.lua:2630: Attempt to access a private function 'PickupInventoryItem' from insecure code. The callstack became untrusted 3 stack frame(s) from the top.
stack traceback:
EsoUI/Ingame/Inventory/InventorySlot.lua:2630: in function '(anonymous)'
|caaaaaa<Locals> inventorySlot = ud, bag = 6, index = 39 </Locals>|r
EsoUI/Ingame/Utility/ZO_SlotUtil.lua:14: in function 'RunHandlers'
|caaaaaa<Locals> handlerTable = [table:1]{}, slot = ud, handlers = [table:2]{}, i = 1 </Locals>|r
(tail call): ?
ZO_StackSplitSource_DragStart:4: in function '(main chunk)'
|caaaaaa<Locals> self = ud, button = 1 </Locals>|r
if you try to drag any item from the crafting table inventory row:
Lua Code:
local origSmithingSetMode = ZO_Smithing.SetMode
ZO_Smithing.SetMode = function(smithingCtrl, mode, ...)
local retVar = origSmithingSetMode(smithingCtrl, mode, ...)
---Your addon post hook code here
return retVar
Same for ZO_Enchanting.OnModeUpdated!
Error happens at the craftbag as well then as it seems.
Hope we can get another working PostHook so addons lik AdvancedFilters and others can work together without problems. In the past it had to be the posthook and to ZO_Smithing and ZO_Enchanting to make them all work together.
Edit
Info from sirinsidiator for
SMITHING
That's because SetMode calls the SetHidden method for each panel, which in turn calls PerformFullRefresh on the crafting intenvories down the line, which is what creates the inventory slots.
You could try to hook into e.g. SMITHING.researchPanel.SetHidden instead.
It is the last function call in SetMode and it doesn't use a craftinginventory so cannot taint any code.
If you PreHook it and use something like
Lua Code:
local smithingMode = SMITHING.mode
you can run your code with the smithingMode variable again.
|
Smithing - Alternative
You can also PreHook EACH panel's SetHidden function of the SMITHING variable (like SMITHING.refinePanel or SMITHING.deconstructionPanel) and execute your code there.
Attention:
But the SetHidden function is called for EACH panel of the crafting table (e.g. refine, create, deconstruction, improve, research, furniture recipes) EACH time you change ANY of them.
So if you change from deconstruction to refine, deconstruction will be SetHidden(true), refine will be SetHidden(false) and ALL others will be SetHidden(true) as well! So be sure to check if the isHidden parameter is false to "apply your code at this panel properly", and check which panel you currently are inside your function code.
Enchanting
Both way unfortunately do not work for ENCHANTING as it does not own any "panels", just ENCHANTING.
If your ENCHANTING PostHook of OnModeUpdateddoes not work anymore you can try this tricky solution provided by Shinni e.g. (untested!)
Lua Code:
local secondCall = false
local isPreHook = false
ZO_PreHook(ZO_Smithing, "SetMode", function(self, mode)
if not isPreHook then
-- this is actually a post hook
-- do stuff here
return true -- prevent 2nd execution of SetMode
end
end)
ZO_PreHook(ZO_Smithing, "SetMode", function(self, mode)
if not secondCall then
secondCall = true
return self.SetMode(self, mode)
end
isPreHook = true
end)
Should work for ZO_Enchanting, "OnModeUpdated" as well.
Or use a Zo_PreHook to ENCHANTING.OnModeUpdated with zo_callLater (about 25ms should be enough) to get the correct enchantingMode again.