ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   Messages for crafting stations? (https://www.esoui.com/forums/showthread.php?t=8408)

MaralieRindu 03/16/19 09:23 PM

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.

merlight 03/17/19 05:45 AM

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.

Baertram 03/17/19 11:39 AM

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!

MaralieRindu 03/18/19 02:43 PM

Quote:

Originally Posted by Baertram (Post 37423)
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.

Baertram 03/18/19 03:07 PM

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) )


All times are GMT -6. The time now is 06:02 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI