Thread Tools Display Modes
06/16/20, 10:39 AM   #1
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 32
abilityIndex parameter of GetAbilityIdByIndex()

For the add-on I'm currently developing, I'm using EVENT_EFFECT_CHANGED and I want to compare the 15th parameter (abilityId) to see if that ability is slotted on the users bar (represented by a 2d table). It seems like GetAbilityIdByIndex() is a function I could use to populate the id for each slot on the bar. However, I don't know what the abilityIndex parameter is, or if I can even specify which bar to check (as opposed to function GetSlotBoundId(number actionSlotIndex, number:nilable HotBarCategory hotbarCategory) where you can specify slot and bar)
  Reply With Quote
06/16/20, 11:34 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Best advice: If you are unsure "how to" do something check how ZOs is doing it in their code.
Most of the code is located in the "ingame" folder and then in a subfolder having the name of the control or stuff you are currently working on like "actionbar":
https://github.com/esoui/esoui/tree/...game/actionbar

I cannot find the function GetAbilityIdByIndex anywhere used there so most probably it's not the one you should or could use.
And if so jist try it ingame. An index will normally start with 1 in lua (could be 0 as well).
So try a script like
Lua Code:
  1. /script d(tostring(GetAbilityIdByIndex(1)))
andd see what abilityId it returns. Should be either the ultimate slot or your 1st bar slot 1, or the active bar slot 1 if it's not making any difference in the 2 bars, and the index only works from 1 to 6 (5 slots + 1 ultimate) maybe.

These constants values could help as well:
https://wiki.esoui.com/Constant_Values

Code:
ACTION_BAR_FIRST_NORMAL_SLOT_INDEX = 2
ACTION_BAR_SLOTS_PER_PAGE = 6
ACTION_BAR_ULTIMATE_SLOT_INDEX = 7
You could use a loop like
Lua Code:
  1. --will loop from 2 to 7, increasing by 1. Maybe the values 2 and 7 are not the correct ones though so maybe it starts at 1, you need to chekc this on your own. But it should be okay, as:
  2. --+1 is there because ZOs is using the same (ACTION_BAR_ULTIMATE_SLOT_INDEX+1) for the ultimateslot index! So it's actually 8 not 7. Guess it's really starting at 2 then and not at 1.
  3. for actionButtonIndex=ACTION_BAR_FIRST_NORMAL_SLOT_INDEX, ACTION_BAR_ULTIMATE_SLOT_INDEX+1, 1 do
  4.   d("Slot number: " .. tostring(actionButtonIndex) ", abilityId: " .. tostring(GetAbilityIdByIndex(actionButtonIndex)))
  5. end

Last edited by Baertram : 06/16/20 at 11:42 AM.
  Reply With Quote
06/16/20, 02:44 PM   #3
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 32
Ok, thanks for those resources. Good to know they exist
  Reply With Quote
06/16/20, 05:55 PM   #4
Shadowfen
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 83
Last time I checked on it, the index was an integer from 1 to the number of skills in the line to get the skill from the line table. Unfortunately, the line table has the skills indexed in order of names alphabetically sorted, so the index of the skill may be different depending on the language you are running the client in.
  Reply With Quote
06/17/20, 04:19 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Ah, thanks for the clarification. So this function is not related to the actionBar but the skills window and skill lines.
  Reply With Quote
06/17/20, 04:24 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
From the code at ZOs actionbuttons you can use this small function to check a slotNum (index of the slot, see my first post with the slot indices) if it contains an abilityId:

Lua Code:
  1. local function HasAbility(slotnum)
  2.     local slotType = GetSlotType(slotnum)
  3.     return slotType == ACTION_TYPE_ABILITY
  4. end

And if this returns true the slot's actionButton should provide an abilityId in it's variable .button.actionId.
See here:
https://github.com/esoui/esoui/blob/...utton.lua#L274

And this was determined via this function:
Lua Code:
  1. GetSlotBoundId(slotnum)

So you should be able to get the abilityId this way.
I hope it IS the abilityId
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » abilityIndex parameter of GetAbilityIdByIndex()

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