ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   abilityIndex parameter of GetAbilityIdByIndex() (https://www.esoui.com/forums/showthread.php?t=9219)

QuantumPie 06/16/20 10:39 AM

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)

Baertram 06/16/20 11:34 AM

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

QuantumPie 06/16/20 02:44 PM

Ok, thanks for those resources. Good to know they exist

Shadowfen 06/16/20 05:55 PM

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.

Baertram 06/17/20 04:19 AM

Ah, thanks for the clarification. So this function is not related to the actionBar but the skills window and skill lines.

Baertram 06/17/20 04:24 AM

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


All times are GMT -6. The time now is 11:43 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2014 - 2020 MMOUI