Thread Tools Display Modes
Yesterday, 04:03 PM   #1
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 21
Question Deconstruction tab

hello,

I need your help, I've tried many things from the wiki but in vain for so long.

I'd like to create a function that will run only when on the deconstruction tab of a crafting station. of course on crafting station interact works for the whole station interacting but I'd like to avoid unnecessary computing.

I'm a beginner though yesterday I was quite happy and thought I had quit the snowplow but no, too soon and I twisted my brain

Last edited by Saint-Ange : Yesterday at 04:11 PM. Reason: for clarity
  Reply With Quote
Yesterday, 06:53 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 418
You'd want to add something to the deconstruction scene. Unfortunately, I don't usually work with scenes, so I'm not sure of the exact functions, but it might be something like UNIVERSAL_DECONSTRUCTION_KEYBOARD_SCENE:AddFragment(https://github.com/esoui/esoui/blob/...cenes.lua#L219)


If that doesn't work, you could also check out https://github.com/esoui/esoui/blob/...n_keyboard.lua and https://github.com/esoui/esoui/blob/...nel_shared.lua
and find some function that you could hook.
  Reply With Quote
Today, 05:24 AM   #3
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 21
Originally Posted by Dolgubon View Post
..
These link to valuable information, I don't know how I'll use them yet for my specific need but crossing that information and other developers deconstruction related add-ons I might find a solution.

Thank you very much!
  Reply With Quote
Today, 07:10 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,175
The deconstruction tab is bundled to the SMITHING global variable, and in there to the panels, like this:
Code:
SMITHING.deconstructionPanel
You can use merTorchbug improved and inspect that ingame by typing /tb SMITHING and then you see all the panels in the list, like
creationPanel, deconstructionPanel, improvementPanel etc.

If you want to know if the panel changes from e.g. refine to deconstruction, you need to PostHook the function "SetMode" in SMITHING.
But attention: As many addons already hook into the "class" ZO_Smithing, and not the "object" SMITHING (like AdvancedFilters and others do) you better should also hook the "class" ZO_Smithing function directly to make all addons compatible!

Code:
local function HookSmithingSetMode(objectVar, mode)
-[[
            --Smithing modes
            SMITHING_MODE_ROOT = 0
            SMITHING_MODE_REFINMENT = 1
            SMITHING_MODE_CREATION = 2
            SMITHING_MODE_DECONSTRUCTION = 3
            SMITHING_MODE_IMPROVEMENT = 4
            SMITHING_MODE_RESEARCH = 5
            SMITHING_MODE_RECIPES = 6
        ]]
 if mode == SMITHING_MODE_DECONSTRUCTION  then
  --do your stuff
 end
end
SecurePostHook(ZO_SMITHING, "SetMode", HookSmithingSetMode)

These panels got an inventory and that inventory got a "ChangeFilter" function which controls if you switched between "Armor" and "Weapon" e.g.
A PreHook to these function or a postHook, may help you to do your extra stuff you want there.
If you do a Prehook you might have to wait a few milliseconds (15 was a good for the start) so that all was done properly there in vanilla code.
A PostHook shuld be fine to use without the zo_callLater !
Code:
local function ChangeFilterCrafting(smithingObject, filterData)
...
end

ZO_PreHook(SMITHING.deconstructionPanel.inventory,   "ChangeFilter",     function(...) zo_callLater(ChangeFilterCrafting, 15) end)

--or
ZO_PosthHook(SMITHING.deconstructionPanel.inventory,   "ChangeFilter",  ChangeFilterCrafting)

Remember to do that AFTER or IN your EVENT_ADD_ON_LOADED callback and not somewhere else or before!



The universal deconstruction NPC's UI is quite different, so if you want to support that too it get's more complicated and you should learn how normal smithing class and functions work first!
  Reply With Quote
Today, 08:26 AM   #5
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 21
Originally Posted by Baertram View Post
..
Thank you very much!
I'll start simple, even if there's no simple for me in lua yet.
Just know that your help, your time, Dolgubon's and yours are much appreciated.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Deconstruction tab


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off