ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Event to detect a skill on your bar changing? (https://www.esoui.com/forums/showthread.php?t=9212)

QuantumPie 06/13/20 03:08 PM

Event to detect a skill on your bar changing?
 
Is there an event that allows you to detect if a player slots / replaces an ability with a new one on their bar? Looking at the wiki, EVENT_ACTION_SLOT_ABILITY_SLOTTED seemed like the most straightforward event but that was removed in 10028. I've tried EVENT_ACTION_SLOT_UPDATED and EVENT_ACTION_SLOT_STATE_UPDATED but the first never fires when I change an ability and the later gets called for every actionSlotIndex if I replace an ability or bar swap. EVENT_HOTBAR_SLOT_CHANGE_REQUESTED also looked promising but I couldn't figure out what triggers it (swapping abilities clearly doesn't). Is there anything I'm missing or is this behavior not possible?

Scootworks 06/13/20 03:19 PM

you could try to hook that function:

ZO_ActionBarAssignmentManager:TryToSlotNewSkill(skillData)

QuantumPie 06/13/20 03:46 PM

Quote:

Originally Posted by Scootworks (Post 41506)
you could try to hook that function:

ZO_ActionBarAssignmentManager:TryToSlotNewSkill(skillData)

What exactly do you mean by hooking? I also don't think that does what I need. I don't want the addon to actually change the user's abilities, just detect if they are manually changed and update a table with that info (to track what is on a users bars, currently it only happens when the UI is reloaded, and doesn't reflect any changes the user makes to their bars onwards).

Scootworks 06/13/20 04:08 PM

doesn't matter, you can listen to this:


Lua Code:
  1. ACTION_BAR_ASSIGNMENT_MANAGER:RegisterCallback("SlotUpdated", function(hotbarCategory, actionSlotIndex, isChangedByPlayer)
  2.     d(hotbarCategory, actionSlotIndex, isChangedByPlayer)
  3. end)

QuantumPie 06/13/20 04:12 PM

After learning you can use Zgoo with /zgoo events to track them, I found EVENT_SKILL_RESPEC_RESULT triggers when I change abilities, but I don't know which one. I'll just have to re-process all the slots once the event is called.

Scootworks 06/13/20 04:16 PM

typing my code above with a /script into the chat, you will see what happens if you gonna change a slot

Baertram 06/13/20 04:28 PM

Quote:

Originally Posted by QuantumPie (Post 41509)
After learning you can use Zgoo with /zgoo events to track them, I found EVENT_SKILL_RESPEC_RESULT triggers when I change abilities, but I don't know which one. I'll just have to re-process all the slots once the event is called.

Not everything can be managed via events! Either there is no event for your purpose or you use it but it was not designed for your purpose, like in this case here:
This event is NOT for normal slot changes, it's about RESPECcing your skills. I wouldn't use this for your purpose as you cannot be sure it will always fire on a skill slot change (in the future e.g.).

But the CallbackManager was designed to be used for such purposes. You register a "callback" function to the fired event (here "OnSlotUpdated") and can run your code then. That's how ZOs does mutliple things in their code as well.

So try Scootworks callback function on the SlotUpdated callback fired by ACTION_BAR_ASSIGNMENT_MANAGER.
It provides you the actioNSlotIndex and everything should be what you are searching for.


And "Hooking" is explained here:
https://wiki.esoui.com/How_to_run_yo...eHook/PostHook)

You need to find a function which is called by ZOs code, that's what Scootworks tried to show you with his first post.
Then you Pre or PostHook to it and run your code afterwards, using the function's own parameters (like the slotindex etc.).
But this should only be used if there is no EVENT and/or CALLBACK_MANAGER entry defined which you could and should use instead,
as your PreHook code (if returning true e.g. or throwing errors) will break ZOs code, and other addons PreHooking the same or later code of the same object!

andy.s 06/14/20 08:38 AM

Lua Code:
  1. EVENT_ACTION_SLOTS_ALL_HOTBARS_UPDATED

Baertram 06/14/20 11:17 AM

This does not fire for single action slots and not always as only e.g. one of the slot changes, so you would still need to check all slots each time if fires.


All times are GMT -6. The time now is 07:38 AM.

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