Quantcast Messages for crafting stations? - ESOUI
Thread Tools Display Modes
03/16/19, 09:23 PM   #1
MaralieRindu
Join Date: Jul 2015
Posts: 7
Messages for crafting stations?

In "Mass Deconstructor" I'm using EVENT_CRAFTING_STATION_INTERACT to determine when to add buttons to the toolbar for mass deconstruction or mass refining (using KEYBIND_STRIP:AddKeybindButtonGroup).

It seems that there is a time lag between beginning of interaction with the crafting station and the ability to actually interact with the crafting station. Is there a new message I need to be looking for since Murkmire/Wrathstone?

If I add a time delay into the message handler before adding the buttons, the buttons are added just fine.
  Reply With Quote
03/17/19, 05:45 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 679
It might be more reliable to add/remove buttons upon scene transition. See for example: https://github.com/esoui/esoui/blob/...rd.lua#L23-L49

The downside is you'd need to add StateChange callbacks for individual crafting scenes and keyboard / gamepad variants, instead of just one event.
  Reply With Quote
03/17/19, 11:39 AM   #3
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,585
Check the code of DoItAll, it may help you.
Keybinds are added via scene stateChange callback functions.
Please be sure to NOT overwrite the keybsindstriop with your addon but ADD to it so other addons won't get broken. Thank you!
  Reply With Quote
03/18/19, 02:43 PM   #4
MaralieRindu
Join Date: Jul 2015
Posts: 7
Originally Posted by Baertram View Post
Check the code of DoItAll, it may help you.
Keybinds are added via scene stateChange callback functions.
The current version does the same thing MassDeconstructor does, registers for the crafting table interaction message. This happens before the scene change is finished.
  Reply With Quote
03/18/19, 03:07 PM   #5
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,585
For the crafting this is true, but I told you the addon to check the other stuff like BankAll as well:

Lua Code:
  1. local bankScene = SCENE_MANAGER:GetScene("bank")
  2. bankScene:RegisterCallback("StateChange",  function(oldState, newState)
  3.     if(newState == SCENE_SHOWING) then
  4.         --Remove the old keybind if there is still one activated
  5.         if DoItAll.currentKeyStripDef ~= nil then
  6.             KEYBIND_STRIP:RemoveKeybindButtonGroup(DoItAll.currentKeyStripDef)
  7.         end
  8.         KEYBIND_STRIP:AddKeybindButtonGroup(keystripDef)
  9.     elseif(newState == SCENE_HIDDEN) then
  10.         KEYBIND_STRIP:RemoveKeybindButtonGroup(keystripDef)
  11.         --Add the keystrip def to the global vars so we can reach it from everywhere
  12.         DoItAll.currentKeyStripDef = nil
  13.     end
  14. end)

Get the scene for the crafting, use the scene's StateChange callback function to add/remove the keybinds. Try this.
SCENE_MANAGER.currentScene is providing you the current scene if you are at the crafting station.
If the scene is always the same and you need a difference you could check if the scene got fragments below and use the fragment's StateChange callback function then.

And check within the scene which mode is currently activated via a preHook to SMITHING.SetMode to see which mode of the crafting station gets activated (modes = e.g.
--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
)

But as said before: Please do not overwrite the functions in smithing like SetMode or others which will most likely kill other addons! Just prehook them and add e.g. a small delay like 250ms to wait for them to be finished (via zo_callLater(function() --your stuff in here end, 250) )
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Messages for crafting stations?

Thread Tools
Display Modes

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