WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Getting all button spells/states (https://www.wowinterface.com/forums/showthread.php?t=53377)

Sharji 04-24-16 11:07 AM

Getting all button spells/states
 
Hello

It is about TDDps addon. I'm author of it.

I have a problem with multi state bars (for example when rogue gets in stealth, action bar changes to other one). How can I actually read all spells that are beneath all of the buttons? In multiple states? Here is the example code of scaning ElvUI (LibActionButton):

Lua Code:
  1. function TDButton_FetchElvUI()
  2.     local ret = false;
  3.     for x = 1, 10 do
  4.         for i = 1, 12 do
  5.             local button = _G['ElvUI_Bar' .. x .. 'Button' .. i];
  6.             if button then
  7.                 local spellId = button:GetSpellId();
  8.                 if spellId then
  9.                     local actionName, _ = GetSpellInfo(spellId);
  10.                     if actionName then
  11.                         if TDButton_Spells[actionName] == nil then
  12.                             TDButton_Spells[actionName] = {};
  13.                         end
  14.                         ret = true;
  15.                         tinsert(TDButton_Spells[actionName], button);
  16.                     end
  17.                 end
  18.             end
  19.         end
  20.     end
  21.     return ret;
  22. end

Is there a way to make it work? Scanning them each time bar changes does not seem like a good idea

Mazzop 04-24-16 01:47 PM

i think you are sorted as is, just be going thru 120 action slots.
Those extra bars are just slots above 72 - http://wowwiki.wikia.com/wiki/ActionSlot

Sharji 04-24-16 06:32 PM

Nope it does not work as it is now.

I mean maybe they are being read but the actual button does not change it only changes it state.
I can't imagine optimal solution when action bar changes. Typically it would be this event:
ACTIONBAR_PAGE_CHANGED

Basically I want a solution where I can highlight a spell by spell name
Right now i am keeping a reference to a button in table:
Lua Code:
  1. tinsert(TDButton_Spells[actionName], button);
Because each spell can have multiple buttons. But it does not work well with rogue stealth and generally when action bar changes page.

Mazzop 04-25-16 02:37 AM

If rogue uses stealth and first action bar changes, first button there is slot 73, not 1. Maybe there is problem with visual part of your code. Are you using something like button:GetID() to identify buttons/slots?

If you need events, there is a list in ActionBarController.lua - it maybe would be good idea to look there and inside ActionButton.lua too.

Here is exactly what you need, i think - http://wowwiki.wikia.com/wiki/API_GetBonusBarOffset

Sharji 04-25-16 09:08 PM

I have some sort of idea.

Instead of keeping table with spell name -> buttons I could simply calculate the action slot on the fly by this:

Lua Code:
  1. local slotID = rememberedActionSlot[spellName];
  2.     local bonusOffset = ((NUM_ACTIONBAR_PAGES + GetBonusBarOffset() - 1) * NUM_ACTIONBAR_BUTTONS);
  3.     slotID = slotID - bonusOffset;
  4.     local bar = math.floor(slotID / 10) + 1;
  5.     local btn = slotID % 10;
  6.  
  7.     local button = _G['ElvUI_Bar' .. bar .. 'Button' .. btn];

If im not mistaken this should work on original blizzard ui, elvui, supervillian and bartender, buttonforge is completely off this grid so it would need to stay as it is.

Actually, I would just need to first 12 actions, not the rest of them since they are not changing. Am I correct?

Mazzop 04-26-16 02:20 AM

You need condition if GetBonusBarOffset() > 0 for that code to work i think
I not fallow bar and btn variables. Imho bar would be 1 - default, and no idea how to get it, if different. And btn is just new slotID, isnt it?


I use Bartender and you can highly configure all action bar/pages by various states/conditions. Not many ppl probably doing that, but if someone does, only way to track would be dig in Bartender code i guess.

Sharji 04-27-16 05:34 PM

I've got another idea, maybe just not keep cache of first 12 buttons and check them every time something changes? It won't be so time consuming operation with just 12 buttons.


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

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