Quantcast
Getting all button spells/states - WoWInterface
Thread Tools Display Modes
04-24-16, 11:07 AM   #1
Sharji
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: May 2015
Posts: 14
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
  Reply With Quote
04-24-16, 01:47 PM   #2
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
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
  Reply With Quote
04-24-16, 06:32 PM   #3
Sharji
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: May 2015
Posts: 14
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.
  Reply With Quote
04-25-16, 02:37 AM   #4
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
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

Last edited by Mazzop : 04-25-16 at 03:28 AM.
  Reply With Quote
04-25-16, 09:08 PM   #5
Sharji
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: May 2015
Posts: 14
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?

Last edited by Sharji : 04-25-16 at 09:34 PM.
  Reply With Quote
04-26-16, 02:20 AM   #6
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
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.
  Reply With Quote
04-27-16, 05:34 PM   #7
Sharji
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: May 2015
Posts: 14
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.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Getting all button spells/states

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